Skip to content

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

@kkomelin

Description

@kkomelin

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions