modern-uri
modern-uri copied to clipboard
Colons in path are escaped
Version: modern-uri-0.3.4.4
(also occurs on older)
Colons in path pieces are percent-encoded, while it seems to me from https://www.rfc-editor.org/rfc/rfc3986#section-3.3 that they can appear unencoded from the second path piece on.
[nix-shell:~/]$ ghci
GHCi, version 9.0.2: https://www.haskell.org/ghc/ :? for help
ghci> import Data.Text
ghci> import Text.URI
ghci> Right u = mkURI (pack "https://mybusinessbusinessinformation.googleapis.com/v1/categories:batchGet")
ghci> render u
"https://mybusinessbusinessinformation.googleapis.com/v1/categories%3abatchGet"
This gives issues with f.e. Google, which uses colons in paths but does not accept the percent-encoded variant.
RFC 3986 is quite dense. It looks like unless a URI is a "Relative Reference" (basically it is something without a scheme), then :
is allowed in path segments. Otherwise it is forbidden in the very first segment, which makes sense because in that case the prefix (everything before :
) could start looking like a scheme :thinking:
Frankly, I think it is admissible to just allow :
to be unescaped. I may get to doing it myself, but you are welcome to open a PR if you want to speed things up.
This should be fixed now. 0.3.6.0 is on Hackage.