This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
Parse and construct URLs
version 14.0.0
license MIT
native-modules False
elm-version 0.18.0 <= v < 0.19.0
Tag 14.0.0
Committed At 2018-06-10 05:45:21 UTC
elm-tools/parser 2.0.1 <= v < 3.0.0 2.0.1
elm-lang/http 1.0.0 <= v < 2.0.0 1.0.0
elm-lang/core 5.0.0 <= v < 6.0.0 5.1.1

Modules

README

Erl

Codeship Status for sporto/erl

A URL parsing and construction library for ELM

parse a url string

-- Given a url string
url = "http://sam:pass@api.example.com:3000/products/kids?color=red&age=10#toys/1"

Erl.parse url 

-- Returns a Erl.Url record:

{ protocol = "http"
, host = "api.example.com"
, port_ = Just 3000
, pathname = "/products/kids"
, query = [ ( "color", "red" ), ( "age", "10") ]
, hash = "#toys/1"
}

See MDN for more details (https://developer.mozilla.org/en-US/docs/Web/API/Location). Note that in MDN query is called search.

toString

-- Given a Erl.Url record (url):

Erl.toString url 

-- Returns the url as string:

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

Query parsing

There are many ways to parse query strings. E.g. an array might be a[]=1&a[]=2 or a=1&a=2 depending on the web framework or library.

Erl parses the query into a List (String, String). This is a bit more useful than just a string, but not as opinionated as other libraries.

Documentation

Documentation at package.elm-lang.org

Test

yarn install
npm test

Changelog