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

fromString Parser not strict enough #40

Closed twerkmeister closed 4 years ago

twerkmeister commented 4 years ago

The parsing of urls misses an edge case where there is additional invalid info at the end of a url.

in elm repl:

import Url
Url.fromString "https://www.test.org (will be online next week)"

Result: Just { fragment = Nothing, host = "www.test.org (will be online next week)", path = "/", port_ = Nothing, protocol = Https, query = Nothing }

expected Result: Nothing

Also:

import Url
Url.fromString "https://In development"

Result: Just { fragment = Nothing, host = "In development", path = "/", port_ = Nothing, protocol = Https, query = Nothing } : Maybe Url.Url

Expected Result: Nothing

twerkmeister commented 4 years ago

just realized that this is also the case for the default js parser and also in python3. So it seems this is more of a global problem than one of this library