mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
Use Mustermann internally for building prefixed_path
as RegexpBased
pattern
Removed `regexpify` from internal API.
This commit is contained in:
parent
fb9a93ed06
commit
d6e1745ee7
2 changed files with 4 additions and 14 deletions
|
@ -201,7 +201,7 @@ module Sinatra
|
|||
end
|
||||
|
||||
def error(*codes, &block)
|
||||
args = Sinatra::Base.send(:compile!, "ERROR", regexpify(@pattern), block)
|
||||
args = Sinatra::Base.send(:compile!, "ERROR", @pattern, block)
|
||||
codes = codes.map { |c| Array(c) }.flatten
|
||||
codes << Exception if codes.empty?
|
||||
|
||||
|
@ -266,16 +266,7 @@ module Sinatra
|
|||
|
||||
def prefixed_path(a, b)
|
||||
return a || b || // unless a and b
|
||||
a, b = regexpify(a), regexpify(b) unless a.class == b.class
|
||||
path = a.class.new "#{a}#{b}"
|
||||
path = /^#{path}$/ if path.is_a? Regexp and base == app
|
||||
path
|
||||
end
|
||||
|
||||
def regexpify(pattern)
|
||||
pattern = Sinatra::Base.send(:compile, pattern).first.inspect
|
||||
pattern.gsub! /^\/(\^|\\A)?|(\$|\\z)?\/$/, ''
|
||||
Regexp.new pattern
|
||||
Mustermann.new(a.to_s + b.to_s, type: :regular)
|
||||
end
|
||||
|
||||
def prefixed(method, pattern = nil, conditions = {}, &block)
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Sinatra::Namespace do
|
||||
verbs = [:get, :head, :post, :put, :delete, :options]
|
||||
verbs << :patch if Sinatra::VERSION >= '1.3'
|
||||
verbs = [:get, :head, :post, :put, :delete, :options, :patch]
|
||||
|
||||
def mock_app(&block)
|
||||
super do
|
||||
|
@ -689,7 +688,7 @@ describe Sinatra::Namespace do
|
|||
end
|
||||
get('/bar') { }
|
||||
end
|
||||
route[1].should eq '/foo'
|
||||
route[1].should eq Mustermann.new '/foo', type: :regular
|
||||
end
|
||||
|
||||
specify 'prevent app-global settings from being changed' do
|
||||
|
|
Loading…
Reference in a new issue