sporto/erl/2.0.0

NOTE: this package is not compatible with Elm 0.19.1

Erl

Library for parsing and constructing URLs

Definition

type alias Url =
{ protocol : Protocol
, username : Username
, password : Password
, host : Host
, port_ : Port
, path : Path
, fragment : Fragment
, query : Query
}

Url record that holds url attributes

Common Helpers

extractFragment : String -> String

Extract the fragment (hash) from the url

extractHost : String -> String

Extract the host from the url

extractPath : String -> String

Extract the path from the url

extractProtocol : String -> String

Extract the protocol from the url

extractPort : String -> Int

Extract the port from the url

extractQuery : String -> String

Extract the query string from the url

parse : String -> Url

Parse a Url an return a Erl.Url record

parse "http://api.example.com/users/1#x/1?a=1" == Erl.Url{...}
toString : Url -> String

Generate url string from an Erl.Url record

url = {
  protocol = "http",
  username = "",
  password = "",
  host = ["www", "foo", "com"],
  path = ["users", "1"],
  port' = 2000,
  fragment = ["a", "b"],
  query = Dict.empty |> Dict.insert "q" "1" |> Dict.insert "k" "2"
}


Erl.toString url == http://www.foo.com:2000/users/1#a/b?k=2&q=1