elm / url

Build and parse URLs. Useful for HTTP and "routing" in single-page apps (SPAs)
https://package.elm-lang.org/packages/elm/url/latest/
BSD 3-Clause "New" or "Revised" License
75 stars 43 forks source link

Support IPv6 literal #35

Open AlexanderEkdahl opened 4 years ago

AlexanderEkdahl commented 4 years ago

According to https://tools.ietf.org/html/rfc3986#section-3.2.2 for any URL the IPv6 literal must be enclosed in square brackets.

This implementation assumes anything remaining after the brackets is the port.

Valid URLs

> Url.fromString "http://[2001:db8:a0b:12f0::1]/index.html"
Just { fragment = Nothing, host = "[2001:db8:a0b:12f0::1]", path = "/index.html", port_ = Nothing, protocol = Http, query = Nothing }
> Url.fromString "http://[2001:db8:a0b:12f0::1]:80/index.html"
Just { fragment = Nothing, host = "[2001:db8:a0b:12f0::1]", path = "/index.html", port_ = Just 80, protocol = Http, query = Nothing }

Rejected URLs

> Url.fromString "http://[/index.html" -- missing ]
Nothing

This fixes https://github.com/elm/url/issues/12

venkatbvc commented 4 years ago

@evancz i saw you have submitted some PRs in Elm/Url. Don't know who is the Maintainer for this git. Can this code be merged? we are having this issue

venkatbvc commented 4 years ago

@AlexanderEkdahl can you let me know how we can use your fix and compile our code?

AlexanderEkdahl commented 4 years ago

@venkatbvc I am not able to provide support in this matter as I no longer actively work with Elm.

rupertlssmith commented 1 year ago

Lines 167-180 change the whitespace of the code there but do not introduce any code changes. A patch should not introduce whitespace only changes, and only modify the lines it really needs to.

Seems like a good patch other than that.

Can a new minimal patch be made for this?