Module exposing: normalizeOrigin, originMatches, IsValidRedirectURI, IsValidOrigin
// Source: https://github.com/authorizerdev/authorizer | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
package validators
import (
"net/url"
"regexp"
"strings"
)
// normalizeOrigin extracts hostname:port from a URL or origin string.
// Standard ports (80/443) and absent ports are omitted so that
// "https://example.com" and "https://example.com:443" both normalise to "example.com".
func normalizeOrigin(raw string) string {
raw = strings.TrimSpace(raw)
if !strings.HasPrefix(raw, "http://") && !strings.HasPrefix(raw, "https://") {
raw = "https://" + raw
}
u, err := url.Parse(raw)
if err != nil {
return raw
}
host := u.Hostname()
port := u.Port()
if port == "" || po
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key