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

x/pkgsite: https://pkg.go.dev/net/url #59906

Closed
ghost opened this issue Apr 30, 2023 · 2 comments
Closed

x/pkgsite: https://pkg.go.dev/net/url #59906

ghost opened this issue Apr 30, 2023 · 2 comments

Comments

@ghost
Copy link

ghost commented Apr 30, 2023

What is the URL of the page with the issue?

https://pkg.go.dev/net/url

What is your user agent?

Screenshot

What did you do?

I want a option to disable encoding of backslashes and some others chars

func (u *URL) EscapedPath() string {
	if u.RawPath != "" && validEncoded(u.RawPath, encodePath) {
		p, err := unescape(u.RawPath, encodePath)
		if err == nil && p == u.Path {
			return u.RawPath
		}
	}
	if u.Path == "*" {
		return "*" // don't escape (Issue 11202)
	}
	fmt.Println(u.RawPath != "" && validEncoded(u.RawPath, encodePath))
	return escape(u.Path, encodePath)
}

i want something like

func (u *URL) EscapedPath() string {
      if u.DisableEncoding {
		p, err := unescape(u.RawPath, encodePath)
		if err == nil && p == u.Path {
			return u.RawPath
		}
	}
	if u.RawPath != "" && validEncoded(u.RawPath, encodePath) {
		p, err := unescape(u.RawPath, encodePath)
		if err == nil && p == u.Path {
			return u.RawPath
		}
	}
	if u.Path == "*" {
		return "*" // don't escape (Issue 11202)
	}
	fmt.Println(u.RawPath != "" && validEncoded(u.RawPath, encodePath))
	return escape(u.Path, encodePath)
}
@ghost ghost added the pkgsite label Apr 30, 2023
@gopherbot gopherbot added this to the Unreleased milestone Apr 30, 2023
@seankhliao
Copy link
Member

I think at this point it is no longer an escaped path and you should be using the raw path directly.

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Apr 30, 2023
@ghost
Copy link
Author

ghost commented Apr 30, 2023

@seankhliao It would be helpful to have this feature added, as I am currently using fhttp, a modified version of net/http which relies on this function to retrieve the path. If I were to modify the library myself, I would need to manage the fhttp library as well, which is not ideal. Therefore, having a simple variable that can turn off the escaping would be a preferable solution.

@golang golang locked and limited conversation to collaborators Apr 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants