-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Description
What version of Go are you using (go version)?
$ go version go version go1.10.4 linux/amd64
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (go env)?
go env Output
$ go env GOARCH="amd64" GOBIN="" GOCACHE="/home/louis/.cache/go-build" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/home/louis/go" GORACE="" GOROOT="/usr/lib/go-1.10" GOTMPDIR="" GOTOOLDIR="/usr/lib/go-1.10/pkg/tool/linux_amd64" GCCGO="gccgo" CC="gcc" CXX="g++" CGO_ENABLED="1" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build814848893=/tmp/go-build -gno-record-gcc-switches"
What did you do?
package main
import (
"log"
"net/url"
)
func main() {
apiURL, _ := url.Parse("https://gitlab.com")
apiURL.Path = "api/v4/projects/0/repository/files/some%2Ffile/raw"
log.Println(apiURL.String())
}https://play.golang.org/p/SFl-9urTdRL
What did you expect to see?
(%2F)
2009/11/10 23:00:00 https://gitlab.com/api/v4/projects/0/repository/files/some%2Ffile/raw
What did you see instead?
(%252F)
2009/11/10 23:00:00 https://gitlab.com/api/v4/projects/0/repository/files/some%252Ffile/raw
I have to build an URL that contains both slashes and encoded slashes, because I'm using the GitLab API:
GET /projects/:id/repository/files/:file_path/rawParameters:
file_path(required) - Url encoded full path to new file. Ex. lib%2Fclass%2Erbref(required) - The name of branch, tag or commit
But when I call URL.String(), the path is escaped again. I read that this is intended behavior:
To obtain the path, String uses u.EscapedPath().
However, there seems to be no way to convert the URL to a string without automatically escaping the path. I think this should be an option for the URL.String() method, or there should be an URL.RawString() method of some kind.
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.