Documentation ¶
Index ¶
- Constants
- func AddPort(u string, p string) (string, error)
- func AddProtocol(u string, p string) (string, error)
- func AddTrailingDot(u string) (string, error)
- func AddTrailingSlash(u string) (string, error)
- func DefaultProtocol(u string) (string, error)
- func ForceHttp(u string) (string, error)
- func ForceHttps(u string) (string, error)
- func IsEmpty(u string) bool
- func IsValid(u string) bool
- func LowerCase(u string) string
- func Normalize(s string) (string, error)
- func Scheme(u string) (string, error)
- func StripAuthentication(u string) (string, error)
- func StripHash(u string) (string, error)
- func StripPort(u string) (string, error)
- func StripProtocol(u string) (string, error)
- func StripTextFragment(u string) (string, error)
- func StripTrailingDot(u string) (string, error)
- func StripTrailingSlash(u string) (string, error)
- func StripWWW(u string) (string, error)
- func TrimURL(u string) string
Constants ¶
const ( URLPort = `(:(\d{1,5}))` URL = `^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?` HTTP_REGEXP = `^(?:[a-zA-Z.-]+:)?\/\/` WWW_REGEXP = `(www\.)` FHTTP_REGEXP = `^(?:https:)` FHTTPS_REGEXP = `^(?:http:)` SHASH_REGEXP = `(#.*)` SAUTH_REGEXP = `^((?:\w+:)?\/\/)?[^@/]+@` TAIL_REGEXP = `\/$` TAILDOT_REGEXP = `\.$` COLON_REGEXP = `:$` )
Basic regular expressions for validating strings
Variables ¶
This section is empty.
Functions ¶
func AddPort ¶
AddPort attaches the specified port to the end of URL Accepts URL and Port Number as a string argument if string matches the patterns (pattern is regular expression) then returns the modified string with port number and nil In case of error return is empty string with a customized error
func AddProtocol ¶
AddProtocol attaches the specified Protocol to the URL Accepts URL and Protocol as a string argument if string matches the patterns (pattern is regular expression) then returns the modified string with protocol and nil In case of error return is empty string with a customized error
func AddTrailingDot ¶
AddTrailingDot attaches the dot (.) to the end of URL Accepts URL as a string argument if string matches the patterns (pattern is regular expression) then returns the modified string and nil In case of error return is empty string with a customized error
func AddTrailingSlash ¶
AddTrailingSlash attaches the / to the end of URL Accepts URL as a string argument if string matches the patterns (pattern is regular expression) then returns the modified string and nil In case of error return is empty string with a customized error
func DefaultProtocol ¶
DefaultProtocol attaches the http:// to the URL Accepts URL as a string argument if string matches the patterns (pattern is regular expression) then returns the modified string and nil In case of error return is empty string with a customized error
func ForceHttp ¶
ForceHttp converts the URL from https to http Accepts URL as a string argument if string matches the patterns (pattern is regular expression) then returns the modified string and nil In case of error return is empty string with a customized error
func ForceHttps ¶
ForceHttps converts the URL from http to https Accepts URL as a string argument if string matches the patterns (pattern is regular expression) then returns the modified string and nil In case of error return is empty string with a customized error
func IsEmpty ¶
IsEmpty checks URL is empty or not IsEmpty is used by every function in the library Accepts URL as a string argument if string matches the patterns (pattern is regular expression) then returns true, else false
func IsValid ¶
IsValid checks if URL is in format with the URL Pattern IsValid is used by every function in the library Accepts URL as a string argument if string matches the patterns (pattern is regular expression) then returns true, else false
func LowerCase ¶
LowerCase checks if the passed URL is in lowercase Accepts URL as a string argument if string matches the patterns (pattern is regular expression) then it returns the lowercase string
func Normalize ¶
Normalize is a generalized method for normalizing URL Accepts URL as a string argument Returns the normalized string and nil In case of error return is a unambiguous string with a customized error
func Scheme ¶
Scheme presents us with the scheme or portocol of the URL internally Scheme uses url.Parse and scheme functions from url package Accepts URL as a string argument if string matches the patterns (pattern is regular expression) then Returns the modified string and nil In case of error return is empty string with a customized error
func StripAuthentication ¶
StripAuthentication removes authentication from the end of URL Expected input format "user:password@@example.com", "https://user:password@@example.com" Accepts URL as a string argument if string matches the patterns (pattern is regular expression) then Returns the modified string and nil In case of error return is empty string with a customized error
func StripHash ¶
StripHash removes the # and contents after #example from URL Accepts URL as a string argument if string matches the patterns (pattern is regular expression) then Returns the modified string and nil In case of error return is empty string with a customized error
func StripPort ¶
StripPort detaches the port from URL Accepts URL as a string argument if string matches the patterns (pattern is regular expression) then returns the modified string with port number and nil In case of error return is empty string with a customized error
func StripProtocol ¶
StripProtocol removes the protocol from URL Accepts URL as a string argument if string matches the patterns (pattern is regular expression) then Returns the modified string and nil In case of error return is empty string with a customized error
func StripTextFragment ¶
StripTextFragment removes text fragments from the end of URL Accepts URL as a string argument if string matches the patterns (pattern is regular expression) then Returns the modified string and nil In case of error return is empty string with a customized error
func StripTrailingDot ¶
StripTrailingDot removes the dot (.) from the end of URL Accepts URL as a string argument if string matches the patterns (pattern is regular expression) then Returns the modified string and nil In case of error return is empty string with a customized error
func StripTrailingSlash ¶
StripTrailingSlash removes TrailingSlash / from the end of URL Accepts URL as a string argument if string matches the patterns (pattern is regular expression) then Returns the modified string and nil In case of error return is empty string with a customized error
Types ¶
This section is empty.