Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sporto/erl
URL parsing library for ELM
https://github.com/sporto/erl
elm
Last synced: about 1 month ago
JSON representation
URL parsing library for ELM
- Host: GitHub
- URL: https://github.com/sporto/erl
- Owner: sporto
- Created: 2015-11-10T21:26:08.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-09-29T07:42:26.000Z (about 6 years ago)
- Last Synced: 2024-06-18T21:39:56.608Z (6 months ago)
- Topics: elm
- Language: Elm
- Homepage: http://package.elm-lang.org/packages/sporto/erl/latest
- Size: 259 KB
- Stars: 27
- Watchers: 3
- Forks: 12
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Erl
[ ![Codeship Status for sporto/erl](https://codeship.com/projects/74c708d0-6c07-0133-ba44-0e105eb8924a/status?branch=master)](https://codeship.com/projects/115393)
A URL parsing and construction library for ELM
## elm/url/
As of Elm 0.19, Elm core has a package works very similarly to Erl. See .
## `parse` a url string
```elm
-- Given a url string
url = "http://sam:[email protected]: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`
```elm
-- 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](http://package.elm-lang.org/packages/sporto/erl/latest/Erl)
## Test
```
yarn install
npm test
```## [Changelog](https://github.com/sporto/erl/blob/master/changelog.md)