Skip to content

Instantly share code, notes, and snippets.

@sporkmonger
Created November 16, 2008 01:28
Show Gist options
  • Save sporkmonger/25355 to your computer and use it in GitHub Desktop.
Save sporkmonger/25355 to your computer and use it in GitHub Desktop.
require "addressable/uri"
Addressable::URI.parse(
 "http://example.com/a/b/c/?one=1&two=2#foo"
).extract_mapping(
 "http://{host}/{-suffix|/|segments}?{-join|&|one,two,bogus}\#{fragment}"
)
#=> {
 "host" => "example.com",
 "segments" => ["a", "b", "c"],
 "one" => "1",
 "two" => "2",
 "fragment" => "foo"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment