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
74 stars 43 forks source link

fromString incorrectly deems invalid URL string as a URL #33

Closed supermacro closed 5 years ago

supermacro commented 5 years ago

Example from elm repl

> import Url

> Url.fromString "gio"
Nothing : Maybe Url.Url

> Url.fromString "https://"
Nothing : Maybe Url.Url

> Url.fromString "https://g"
Just { fragment = Nothing, host = "g", path = "/", port_ = Nothing, protocol = Https, query = Nothing }

The first 2 calls to fromString are correct. However, the 3rd call (Url.fromString "https://g") generates a Just Url when it should be returning a Nothing.

I am no expert, but I do believe a valid URL requires a TLD.

I also validated this against npm's validator library. Code here

supermacro commented 5 years ago

Closing this issue because TLD's are not required as I have just learned!