Skip to content

net/url: new JoinPath function and method use Path instead of EscapedPath() #53763

@gazerro

Description

@gazerro

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

go version go1.19rc1 darwin/amd64

Does this issue reproduce with the latest release?

Yes.

What did you do?

package main

import "net/url"

func main() {
	u, err := url.JoinPath("https://www.example.com/a%2fb", "a%2fb")
	if err != nil {
		panic(err)
	}
	print(u)
}

https://go.dev/play/p/YS_-s65X9n2?v=gotip

What did you expect to see?

https://www.example.com/a%2fb/a%2fb

What did you see instead?

https://www.example.com/a/b/a%2fb

How to fix

In the JoinPath method,

elem = append([]string{u.Path}, elem...)

should be written as

elem = append([]string{u.EscapedPath()}, elem...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    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