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