Skip to content

azer/urls

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

urls

URL Library for Kaktus

Install

$ npm install kaktus/urls

API

.clean

Removes protocol, www. and unnecessary characters at the end of the url (if exists).

urls.clean('http://www.yolo.com/?&')
// => yolo.com

.page

Returns clean page URL (applies .clean and also removes hashbang part)

urls.page('http://yolo.com#yo=lo')
// => yolo.com

.hostname

Returns the hostname

urls.hostname('http://yolo.co.uk')
// => yolo.co.uk

.protocol

Returns the protocol

urls.hostname('http://yolo.co.uk')
// => http

.normalize

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

.isSearchQuery

Returns true if given input is a search query rather than URL

urls.isSearchQuery('hello world')
// => true

urls.isSearchQuery('yolo.com')
// => false

.isURL

Returns true if given input is a URL

urls.isURL('hello world')
// => false

urls.isURL('yolo.com')
// => true

About

URL Library for Kaktüs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages