I’ve read a lot about this and if I got it correctly, Dhall support this since 2018 and back then the solution was to quote the component of the path containing a space. However, testing this with the Haskell implementation of dhall, version 1.40.2 and also 1.41.2 gives an error message:
> dhall <<< `https://api.github.com/repos/account/repo/contents/templates/"mat cat"/file.dhall using [...]`
dhall-1.41.2:
Error: Invalid input
(input):1:74:
|
1 | https://api.github.com/repos/account/repo/contents/templates/"mat cat"/file.dhall using [...]
unexpected '"'
expecting "→", "∧", "≡", "⩓", "⫽", '%', '/', '?', --, ->, //, //\\, /\, :, ===, end of input, keyword, operator, or whitespace
So I looked into the source code and found out that:
pathComponent :: ComponentType -> Parser Text
pathComponent componentType = do
...
case componentType of
FileComponent -> quotedPathData <|> pathData
URLComponent -> pathData
quoted paths are only allowed for file path components. I also found a blog post that quoted paths were deprecated and one should use %
escaping instead. I guess the correct way to code a space in a URL is %20
, but I can’t get it to work:
> dhall repl
Welcome to the Dhall v1.41.2 REPL! Type :help for more information.
⊢ https://api.github.com/repos/account/repo/contents/templates/mat%20cat/file.dhall using [...]
Error: Remote file not found
HTTP status code: 404
URL: https://api.github.com/repos/account/repo/contents/templates/mat%2520cat/file.dhall
Message:
1│ {"message":"Not Found","documentation_url":"https://docs.github.com/rest/reference/repos#get-repository-content"}
Why is my %20
converted to %2520
? I couldn’t find the code that did this. Dhall 1.40.2 behaves the same. Is this a bug or am I doing it wrongly?