validator

package
v0.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// RegexForGitHTTP defines a regular expression with capture groups that can be used to parse/validate
	// HTTP(S) URLs
	RegexForGitHTTP = fmt.Sprintf(
		`^(?P<%s>http[s]*)\:\/\/`+
			`(?:(?P<%s>[a-zA-Z0-9\_\.\-]+)`+
			`(?:\:(?P<%s>.*))?@)*`+
			`(?P<%s>[a-zA-Z0-9\.\-\_]+)`+
			`(?:\:(?P<%s>\d+?))?\/`+
			`(?P<%s>[a-zA-Z0-9\.\-\_]+)\/`+
			`(?P<%s>[a-zA-Z0-9\/\.\-\_]+)`+
			`\.git$`,
		keySchema, keyUsername, keyPassword, keyHostname, keyPort, keyUser, keyPath,
	)

	// RegexForGitSSH defines a regular expression with capture groups that can be used to parse/validate
	// SSH URLs
	RegexForGitSSH = fmt.Sprintf(
		`^(?P<%s>[a-zA-Z0-9\-\_\.]+?)@`+
			`(?P<%s>[a-zA-Z0-9\-\_\.]+?):`+
			`(?:(?P<%s>\d*?)\/)?`+
			`(?P<%s>[a-zA-Z0-9\-\_\.]+)\/`+
			`(?P<%s>[a-zA-Z0-9\-\_\.\/]+?)`+
			`\.git$`,
		keyUsername, keyHostname, keyPort, keyUser, keyPath,
	)
)

Functions

func IsGitHTTPUrl

func IsGitHTTPUrl(test string) bool

IsGitHTTPUrl is used for testing if a provided :test string is a valid HTTP(S) URL

func IsGitSSHUrl

func IsGitSSHUrl(test string) bool

IsGitSSHUrl is used for testing if a provided :test string is a valid SSH URL

Types

type URL

type URL struct {
	Schema   string
	Username string
	Password string
	Hostname string
	Port     string
	User     string
	Path     string
	Query    string
}

URL defines the structure returnable by ParseURL

func ParseURL

func ParseURL(remoteURL string) (*URL, error)

ParseURL returns a new *URL based on the remoteURL

func (URL) String

func (u URL) String() string

String returns a string output of the URL instance

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL