JoinPathWithHostPrefix returns a SafeURL for the given host prefix and the path made up of the given components. It returns an error if any component is exactly "..", which would traverse the URL path and change which resource it addresses.
(hostPrefix string, components ...string)
| 62 | // made up of the given components. It returns an error if any component is exactly |
| 63 | // "..", which would traverse the URL path and change which resource it addresses. |
| 64 | func JoinPathWithHostPrefix(hostPrefix string, components ...string) (*MutableSafeURL, error) { |
| 65 | if err := checkTraversal(components); err != nil { |
| 66 | return nil, err |
| 67 | } |
| 68 | return &MutableSafeURL{prefix: hostPrefix, components: components}, nil |
| 69 | } |
| 70 | |
| 71 | // checkTraversal returns an error if any component is exactly "..". Such a component |
| 72 | // survives percent-encoding as a real path segment and would traverse the URL path. |