-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
Description
https://tools.ietf.org/html/rfc3986 2.2: Reserved characters: @ is a reserved character, the only place it should be in the url is between username@host
What version of Go are you using (go version)?
- Current version of the go playground
What operating system and processor architecture are you using?
- Current version of the go playground
What did you do?
What did you expect to see?
What did you see instead?
http://play.golang.org/p/WvjfmMKJIw
package main
import (
"fmt"
"net/url"
)
func main() {
var Url *url.URL
Url, err := url.Parse("http://www.example.com")
if err != nil {
panic("boom")
}
Url.Path += "/users/1/recipients/devon.jones@sendgrid.com"
fmt.Printf("Encoded URL is %q\n", Url.String())
}Encoded URL is "http://www.example.com/users/1/recipients/devon.jones@sendgrid.com"
shows that if I url encode with @ in the path, it leaves it. But if I use other reserved characters, like ?, it will properly encode them:
http://play.golang.org/p/FT-JyJ-DnG
package main
import (
"fmt"
"net/url"
)
func main() {
var Url *url.URL
Url, err := url.Parse("http://www.example.com")
if err != nil {
panic("boom")
}
Url.Path += "/users/1/recipients/devon.jones?sendgrid.com"
fmt.Printf("Encoded URL is %q\n", Url.String())
}Encoded URL is "http://www.example.com/users/1/recipients/devon.jones%3Fsendgrid.com"