# File lib/rack/urlmap.rb, line 15
    def initialize(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('/')

        [host, location, app]
      }.sort_by { |(h, l, a)| [-l.size, h.to_s.size] }  # Longest path first
    end