19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/rack/urlmap.rb', line 19
def remap(map)
@mapping = map.map { |location, app|
if location =~ %r{\Ahttps?://(.*?)(/.*)}
host, location = $1, $2
else
host = nil
end
unless location[0] == ?/
raise ArgumentError, "paths need to start with /"
end
location = location.chomp('/')
match = Regexp.new("^#{Regexp.quote(location).gsub('/', '/+')}(.*)", nil, 'n')
[host, location, match, app]
}.sort_by { |(h, l, _, _)| [h ? -h.size : (-1.0 / 0.0), -l.size] }
end
|