UrlIssue12Ipv6HostTest
Tags:elm19-bug
Issue: elm/url#12
`Url.fromString` rejects URLs whose host is an IPv6 address. <https://github.com/elm/url/issues/12> Elm 0.19.1 (elm/url 1.0.0) returns `Nothing` for "http://[::1]:7272/ui/" because it treats every `:` in the authority as a port separator. The URL is valid (RFC 3986 IP-literal host) and must parse, with host "[::1]" and port 7272.
Results
elm-0.19.1
failran in 49 msMissing pattern: host: Just "[::1]" --- output --- Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. host: Nothing port: Nothing
elm-0.19.2
failran in 56 msMissing pattern: host: Just "[::1]" --- output --- Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. host: Nothing port: Nothing
elm-0.19.3
failran in 64 msMissing pattern: host: Just "[::1]" --- output --- Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. host: Nothing port: Nothing
lamdera-1.5.0
failran in 37 msMissing pattern: host: Just "[::1]" --- output --- host: Nothing port: Nothing
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-url/UrlIssue12Ipv6HostTest] in its title.
Source
The -- CHECK: lines give the expected output.
module UrlIssue12Ipv6HostTest exposing (main)
{-| `Url.fromString` rejects URLs whose host is an IPv6 address.
<https://github.com/elm/url/issues/12>
Elm 0.19.1 (elm/url 1.0.0) returns `Nothing` for "http://[::1]:7272/ui/" because it treats every
`:` in the authority as a port separator. The URL is valid (RFC 3986 IP-literal host) and must
parse, with host "[::1]" and port 7272.
-}
-- TAGS: elm19-bug
-- CHECK: host: Just "[::1]"
-- CHECK: port: Just (Just 7272)
import Html exposing (text)
import Url
main =
let
url =
Url.fromString "http://[::1]:7272/ui/"
_ =
Debug.log "host" (Maybe.map .host url)
_ =
Debug.log "port" (Maybe.map .port_ url)
in
text "done"