Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalization does not add / to path. #59

Open
fisx opened this issue Oct 10, 2021 · 2 comments
Open

Normalization does not add / to path. #59

fisx opened this issue Oct 10, 2021 · 2 comments

Comments

@fisx
Copy link
Contributor

fisx commented Oct 10, 2021

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}

import Control.Lens ((.~))
import Imports
import URI.ByteString
import URI.ByteString.QQ (uri)

main :: IO ()
main = do
  let want, have :: ByteString
      want = "http://example.com/1"
      have = normalizeURIRef' aggressiveNormalization ([uri|http://example.com/|] & pathL .~ "1")
  print want
  print have
  print $ want == have

Result:

*Main> :main
"http://example.com/1"
"http://example.com1"
False

If it's ok to remove the / from the domain, shouldn't it be ok to add it again in the path?

@MichaelXavier
Copy link
Contributor

I think the problem might be how you're setting the path. The leading / is part of the path. If you show [uri|http://example.com/|] you'll see that the / is part of the path, not the domain. Maybe I'm misunderstanding the issue.

@fisx
Copy link
Contributor Author

fisx commented Oct 13, 2021

You're right, I was confused about domain vs. entire URL. But I'm still wondering if the path shouldn't have an implicit leading "/"?

I'm very uncertain now about what I think the library should do. If you don't see an issue, you should probably close this. If you think it's ok to make sure paths always are rendered with a leading "/" let me know, and I'll try to get together a PR.

Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants