def compile(path)
      keys = []
      pattern = path.to_str.gsub(/[^\?\%\\\/\:\*\w]/) { |c| encoded(c) }
      pattern.gsub!(/((:\w+)|\*)/) do |match|
        if match == "*"
          keys << 'splat'
          "(.*?)"
        else
          keys << $2[1..-1]
          "([^/?#]+)"
        end
      end
      [/^#{pattern}$/, keys]
    end
def compile(path)
      keys = []
      pattern = path.to_str.gsub(/[^\?\%\\\/\:\*\w]/) { |c| encoded(c) }
      pattern.gsub!(/((:\w+)|\*)/) do |match|
        if match == "*"
          keys << 'splat'
          "(.*?)"
        else
          keys << $2[1..-1]
          "([^/?#]+)"
        end
      end
      [/^#{pattern}$/, keys]
    end
turn a path string with optional keys (/foo/:bar/:boo) into a
 regexp which will be used when searching for a route

 @param [String] path the path to compile