ValidateUrl returns a validated version of `originUrl` with a scheme prepended (by default http://). Note: when originUrl contains a scheme, the path is removed: ValidateUrl("https://localhost:8080/api/") => "https://localhost:8080" but when it does not, the path is preserved: ValidateUrl("loca
(originUrl string)
| 70 | // |
| 71 | // This is arguably a bug, but changing it might break some cloudflared users. |
| 72 | func ValidateUrl(originUrl string) (*url.URL, error) { |
| 73 | urlStr, err := validateUrlString(originUrl) |
| 74 | if err != nil { |
| 75 | return nil, err |
| 76 | } |
| 77 | return url.Parse(urlStr) |
| 78 | } |
| 79 | |
| 80 | func validateUrlString(originUrl string) (string, error) { |
| 81 | if originUrl == "" { |