Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andre-dietrich/elm-url-extension
A wrapper for elm/url that allows to use other protocols than http and https.
https://github.com/andre-dietrich/elm-url-extension
Last synced: 19 days ago
JSON representation
A wrapper for elm/url that allows to use other protocols than http and https.
- Host: GitHub
- URL: https://github.com/andre-dietrich/elm-url-extension
- Owner: andre-dietrich
- License: bsd-3-clause
- Created: 2021-07-06T11:43:38.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-07-06T11:46:50.000Z (over 3 years ago)
- Last Synced: 2024-05-01T13:58:45.951Z (7 months ago)
- Language: Elm
- Size: 4.88 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Elm-Url-Extension
This is a simple wrapper for the `elm/url` package that allows to use different
protocols than `http` and `https`. The `file` and `ftp` protocols are supported
by default, but as the example shows, you can also define your own custom types.``` elm
import UrlExtension as URL"ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/wiki/Vincent_van_Gogh.html"
|> URL.fromStringWithProtocol ["ipfs", "custom"]
--> Just { fragment = Nothing, host = "bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq", path = "/wiki/Vincent_van_Gogh.html", port_ = Nothing, protocol = CUSTOM "ipfs", query = Nothing }"ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/wiki/Vincent_van_Gogh.html"
|> URL.fromStringWithProtocol ["ipfs", "custom"]
|> Maybe.map URL.toString
--> Just "ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/wiki/Vincent_van_Gogh.html"
```> **Note: For Url parsing it still uses the original functions from the `Url` module.**
## Future Work
Actually it would be great to use also the standards for other web protocols, such as `ftp`,
which allows for example to define `ftp://user:[email protected]`. `@` symbols are not
allowed by `http?s` to be part of the hostname, thus this will not be parsed by this
package...