Documentation
¶
Overview ¶
Package urlparser extracts repository paths from git URLs. Works with any git hosting service, not just the major ones. Inspired by github.com/librariesio/librariesio-url-parser
Index ¶
- func CanonicalURL(rawURL string) string
- func Clean(rawURL string) string
- func ExtractHost(rawURL string) string
- func ExtractOwnerRepo(rawURL string) string
- func ExtractPath(rawURL string) string
- func FirstRepoURL(urls ...string) string
- func IsKnownHost(rawURL string) bool
- func Normalize(rawURL string) string
- func Parse(rawURL string) string
- func ParseFromMap(m map[string]string, priorityKeys ...string) string
- func TryParseURL(rawURL string) *url.URL
- type RepoURL
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanonicalURL ¶
CanonicalURL returns the canonical URL for known hosts, or empty string.
func Clean ¶
Clean removes common noise from git URLs: schemes, auth, brackets, anchors, etc. Returns just the host/path portion ready for further processing.
func ExtractHost ¶
ExtractHost returns the host portion of the URL.
func ExtractOwnerRepo ¶
ExtractOwnerRepo returns just the owner/repo portion.
func ExtractPath ¶
ExtractPath returns just the path portion after the domain.
func FirstRepoURL ¶
FirstRepoURL returns the first URL from the list that parses as a repo.
func IsKnownHost ¶
IsKnownHost returns true if the URL is from a recognized git hosting service.
func ParseFromMap ¶
ParseFromMap extracts a repository URL from common field names in a map.
func TryParseURL ¶
TryParseURL attempts to parse a URL using Go's url.Parse.