Library for parsing and constructing URLs
Parse an url into a Url record
Erl.parse "http://hello.com/users/1?k=1&q=2#a/b"
Ok
{ protocol = "http",
, host = "hello.com",
, port_ = Just 2000,
, pathname = "/users/1",
, query = [ ("k", "1"), ("q", "2") ]
, hash = "a/b",
}Generate an empty Url record
Erl.new ==
{ protocol = ""
, host = ""
, port_ = Nothing
, pathname = ""
, query = []
, hash = ""
}Generate a url string from an Url record
url = { protocol = "http",
, host = "www.hello.com",
, port_ = Just 2000,
, pathname = "/users/1",
, query = [ ("k", "1"), ("q", "2") ]
, hash = "a/b",
}
Erl.toString url == "http://www.hello.com:2000/users/1?k=1&q=2#a/b"Generate a url that starts at the path
url = { protocol = "http",
, host = "www.hello.com",
, port_ = Just 2000,
, pathname = "/users/1",
, query = [ ("k", "1"), ("q", "2") ]
, hash = "a/b",
}
Erl.toAbsoluteString url == "/users/1?k=1&q=2#a/b"
Record that holds url attributes