Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions src/Url.elm
Original file line number Diff line number Diff line change
Expand Up @@ -163,21 +163,30 @@ chompBeforePath : Protocol -> String -> Maybe String -> Maybe String -> String -
chompBeforePath protocol path params frag str =
if String.isEmpty str || String.contains "@" str then
Nothing
else if String.startsWith "[" str then
-- IPv6 literal enclosed in brackets
case String.indexes "]" str of
i :: [] ->
Just <| Url protocol (String.left (i + 1) str) (String.toInt (String.dropLeft (i + 2) str)) path params frag

_ ->
Nothing

else
case String.indexes ":" str of
[] ->
Just <| Url protocol str Nothing path params frag
case String.indexes ":" str of
[] ->
Just <| Url protocol str Nothing path params frag

i :: [] ->
case String.toInt (String.dropLeft (i + 1) str) of
Nothing ->
Nothing
i :: [] ->
case String.toInt (String.dropLeft (i + 1) str) of
Nothing ->
Nothing

port_ ->
Just <| Url protocol (String.left i str) port_ path params frag
port_ ->
Just <| Url protocol (String.left i str) port_ path params frag

_ ->
Nothing
_ ->
Nothing


{-| Turn a [`Url`](#Url) into a `String`.
Expand Down