URL
Useful URL methods. Some methods are based on original TLDs and Country codes. They might not work with brand domains.
address
__.url.address()
Returns the full URL address.
__.url.address(); // https://www.gitbook.com/book/josantana/longdash
domain
__.url.domain( exact: boolean )
Returns the domain name.
__.url.domain(); // gitbook
hash
__.url.hash()
Returns the hash of the URL.
__.url.hash(); // #edit
isexternal
__.url.isExternal( url: string )
Checks if a given url string matches with the current domain. Returns true
of false
.
__.url.isexternal('http://www.github.com/'); // true
param
__.url.param( name: string, reverse: boolean )
Gets a single param from the URL. It will automatically return the first occurrence of this param. If you want to get the last occurrence, flag the reverse
property as true
.
__.url.param('utm_source'); // google
path
__.url.path()
Returns the URL path.
__.url.path(); // /book/josantana/longdash
protocol
__.url.protocol()
Returns the URL protocol.
__.url.protocol(); // https
search
__.url.search()
Returns the URL search query.
__.url.search(); // ?v=k9CbDcOT1e8
subdomain
__.url.subdomain( exact: boolean )
Returns an array with all URL subdomains.
__.url.subdomain(); // www
tld
__.url.tld( exact: boolean )
Returns an array with all Top-Level Domains.
__.url.tld(); // com
Based on URL module from our previous library.