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

Opaque URLs should be normalized too #8

Closed
ghost opened this issue Feb 7, 2015 · 4 comments
Closed

Opaque URLs should be normalized too #8

ghost opened this issue Feb 7, 2015 · 4 comments

Comments

@ghost
Copy link

ghost commented Feb 7, 2015

purell doesn't normalize "opaque" URLs (see documentation for url.URL).

package main

import (
    "fmt"
    "net/url"

    "github.com/PuerkitoBio/purell"
)

func main() {
    u := &url.URL{Scheme: "http", Opaque: "//eXAMPLe.com/%3f"}
    fmt.Println(purell.NormalizeURL(u, purell.FlagLowercaseHost|purell.FlagUppercaseEscapes))
}

Output: http://eXAMPLe.com/%3f

@mna
Copy link
Member

mna commented Feb 7, 2015

I guess it should, to be honest I'm not sure I completely grasp the opaque field. I don't really have a need for it, but if someone cares enough to provide a PR (with tests), I'll be happy to merge.

@pkieltyka
Copy link

I feel this is an important issue and here's something related:

u, _ := url.Parse("www.youtube.com")
fmt.Println(purell.NormalizeURL(u, purell.FlagsUsuallySafeGreedy))

will print /www.youtube.com

@mna
Copy link
Member

mna commented Feb 8, 2015

This is indeed an important issue and is addressed in PR #5 (merged in fix-relative-paths branch for now, in master hopefully soon). This is unrelated to the Opaque field that is the subject of this issue, though (see e.g. http://play.golang.org/p/VP8o_CjrPA).

@mna
Copy link
Member

mna commented Mar 28, 2015

Closing, I think the Opaque field is meant to be left untouched. The other issue discussed here by pkieltyka is fixed in master now.

@mna mna closed this as completed Mar 28, 2015
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