Search code examples
gourl

@ not escaped by url.PathEscape


I'm wondering why using url.PathEscape is not escaping the "@" character.

package main

import (
    "fmt"
    "net/url"
)

func main() {
    path := url.PathEscape("[email protected]")
    fmt.Println(path) //[email protected]
}

I understand the @ character is reserved for the path component of an URI, why is it not escaping it?


Solution

  • Here:

    https://datatracker.ietf.org/doc/html/rfc3986#section-3.3

    "@" is explicitly specified as one of the valid components of a path segment, so there is no need to escape it.