@@ -16,11 +16,12 @@ def initialize(matcher,url=nil,options)
16
16
17
17
attr_reader :matcher , :url , :default_url , :options
18
18
19
- def match? ( path , headers )
20
- match_path ( path , headers ) ? true : false
19
+ def match? ( path , * args )
20
+ match_path ( path , * args ) ? true : false
21
21
end
22
22
23
23
def get_uri ( path , env )
24
+ return nil if url . nil?
24
25
_url = ( url . respond_to? ( :call ) ? url . call ( env ) : url . clone )
25
26
if _url =~/\$ \d /
26
27
match_path ( path ) . to_a . each_with_index { |m , i | _url . gsub! ( "$#{ i . to_s } " , m ) }
@@ -35,11 +36,15 @@ def to_s
35
36
end
36
37
37
38
private
38
- def match_path ( path , headers = nil )
39
- if @options [ :accept_headers ]
40
- match = matcher . match ( path , headers )
41
- else
39
+ def match_path ( path , *args )
40
+ headers = args [ 0 ]
41
+ rackreq = args [ 1 ]
42
+ arity = matcher . method ( :match ) . arity
43
+ if arity == -1
42
44
match = matcher . match ( path )
45
+ else
46
+ params = [ path , ( @options [ :accept_headers ] ? headers : nil ) , rackreq ]
47
+ match = matcher . match ( *params [ 0 ..( arity - 1 ) ] )
43
48
end
44
49
@url = match . url ( path ) if match && default_url . nil?
45
50
match
0 commit comments