Skip to content

Conversation

@bendrucker
Copy link
Contributor

This PR uses url.PathEscape instead of url.QueryEscape to escape path parameters. PathEscape performs what would typically be called "URL encoding" with percents. PathEscape replaces spaces with pluses among other encoding that's suitable for query parameters.

package main

import (
	"fmt"
	"net/url"
)

func main() {
	input := "foo bar"
	fmt.Println("QueryEscape:", url.QueryEscape(input))
	fmt.Println("PathEscape:", url.PathEscape(input))
}
QueryEscape: foo+bar
PathEscape: foo%20bar

https://play.golang.org/p/3gWzjBhMR9C

Escaping was originally added in #3643.

PR checklist

  • Read the contribution guidelines.
  • If contributing template-only or documentation-only changes which will change sample output, build the project beforehand.
  • Run the shell script ./bin/generate-samples.shto update all Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/config/java*. For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

@bendrucker
Copy link
Contributor Author

cc go TC: @antihax @bvwells @grokify @kemokemo @bkabrda

Copy link
Contributor

@bkabrda bkabrda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@wing328 wing328 merged commit f373f20 into OpenAPITools:master Jun 11, 2020
@wing328 wing328 added this to the 5.0.0 milestone Jun 11, 2020
@bendrucker bendrucker deleted the go-path-escape branch June 11, 2020 17:20
@bendrucker
Copy link
Contributor Author

Thanks for the quick merge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants