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: Inconsistent .Path #66047

Closed
sen-lin-glean opened this issue Mar 1, 2024 · 1 comment
Closed

net/url: Inconsistent .Path #66047

sen-lin-glean opened this issue Mar 1, 2024 · 1 comment

Comments

@sen-lin-glean
Copy link

Go version

go version go1.21.7 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/senlin/Library/Caches/go-build'
GOENV='/Users/senlin/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/senlin/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/senlin/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go@1.21/1.21.7/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go@1.21/1.21.7/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21.7'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/0y/13n782px5h37zxnxtrmtyc000000gn/T/go-build1437991706=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

rawUrl := "https://www.example.com?z=1"
addPath := "/a/b"
parsedUrl, _ := url.Parse(rawUrl)
parsedUrl = parsedUrl.JoinPath(addPath)
fmt.Println(parsedUrl.Path)

This outputs a/b. But if the rawUrl has a base path, eg. rawUrl := "https://www.example.com/api?z=1", output will be /api/a/b. This is an inconsistent treatment of leading "/".

What did you see happen?

All the time.

What did you expect to see?

Leading "/" present in all (*URL) .Path variables.

@seankhliao
Copy link
Member

Duplicate of #58605

@seankhliao seankhliao marked this as a duplicate of #58605 Mar 1, 2024
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Mar 1, 2024
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