URL Library for Kaktus
$ npm install kaktus/urls
Removes protocol, www.
and unnecessary characters at the end of the url (if exists).
urls.clean('http://www.yolo.com/?&')
// => yolo.com
Returns clean page URL (applies .clean
and also removes hashbang part)
urls.page('http://yolo.com#yo=lo')
// => yolo.com
Returns the hostname
urls.hostname('http://yolo.co.uk')
// => yolo.co.uk
Returns the protocol
urls.hostname('http://yolo.co.uk')
// => http
Makes given any input a valid URL. If given input is not a URL at all, returns a Yolo search URL.
urls.normalize('yolo.com')
// => http://yolo.com
urls.normalize('hello world')
// => https://google.com/search?q=hello%20world
Returns true if given input is a search query rather than URL
urls.isSearchQuery('hello world')
// => true
urls.isSearchQuery('yolo.com')
// => false
Returns true if given input is a URL
urls.isURL('hello world')
// => false
urls.isURL('yolo.com')
// => true