URL

Useful URL methods. Some methods are based on original TLDs and Country codes. They might not work with brand domains.



__.url.address()

Returns the full URL address.

__.url.address(); // https://www.gitbook.com/book/josantana/longdash

__.url.domain( exact: boolean )

Returns the domain name.

__.url.domain(); // gitbook

__.url.hash()

Returns the hash of the URL.

__.url.hash(); // #edit

__.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

__.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

__.url.path()

Returns the URL path.

__.url.path(); // /book/josantana/longdash

__.url.protocol()

Returns the URL protocol.

__.url.protocol(); // https

__.url.search()

Returns the URL search query.

__.url.search(); // ?v=k9CbDcOT1e8

__.url.subdomain( exact: boolean )

Returns an array with all URL subdomains.

__.url.subdomain(); // www

__.url.tld( exact: boolean )

Returns an array with all Top-Level Domains.

__.url.tld(); // com

Based on URL module from our previous library.