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

net/url: url.IsAbs doesn't take into account schemeless absolute urls #15753

Closed
kkomelin opened this issue May 19, 2016 · 4 comments
Closed

net/url: url.IsAbs doesn't take into account schemeless absolute urls #15753

kkomelin opened this issue May 19, 2016 · 4 comments
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@kkomelin
Copy link

kkomelin commented May 19, 2016

1. What version of Go are you using (go version)?

go version go1.6 linux/amd64

2. What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/kon/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"

3. What did you do?

https://play.golang.org/p/mwe5nXffX6

    url, _ := url.Parse("//example.com")
    if url.IsAbs() {
        fmt.Printf("%v is absolute.", url)
    } else {
        fmt.Printf("%v is relative. Are you sure?", url)
    }

4. What did you expect to see?

//example.com is absolute.

5. What did you see instead?

//example.com is relative.

6. Fix and automated tests provided:

https://github.com/kkomelin/go/commit/a4c6cc8dc3d3a84d74d71343aebe0d456ec6005c

@kkomelin
Copy link
Author

kkomelin commented May 19, 2016

I'm in process of reading the Contribution Guidelines. It is actually longer than fixing the issue ) Let's see if the process is easier that Microsoft's one. They ask to sign a contribution agreement.

@bradfitz
Copy link
Contributor

Sorry, this isn't going to change. The definition has always been what it is now:

// IsAbs reports whether the URL is absolute.                                                                                                     
func (u *URL) IsAbs() bool {
        return u.Scheme != ""
}

Plus I disagree that //example.com is absolute. It's relative to the scheme, so it's still relative.

Perhaps we can just document it more. Feel free to send a change.

@bradfitz bradfitz added this to the Go1.8 milestone May 19, 2016
@kkomelin
Copy link
Author

kkomelin commented May 19, 2016

Thanks @bradfitz for your answer and clarification. Then I will add a special method to my application code.

@rakyll rakyll changed the title url.IsAbs doesn't take into account schemeless absolute urls net/url: url.IsAbs doesn't take into account schemeless absolute urls May 19, 2016
@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 7, 2016
@quentinmit quentinmit modified the milestones: Go1.8Maybe, Go1.8 Oct 7, 2016
@rsc
Copy link
Contributor

rsc commented Oct 19, 2016

Fixed by 1ff1920.

@rsc rsc closed this as completed Oct 19, 2016
@golang golang locked and limited conversation to collaborators Oct 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants