
A cross-platform utility library to work
with URLs
npm install urley --save
npm install urley --save
npm install urley --save
A cross-platform library with a collection of handy utilites to work with URLs
Returns Boolean
if the given string is an absolute URL. https://seoclarity.net/resources/knowledgebase/difference-relative-absolute-url-15325/
isAbsolute("https://google.com")
// Returns => true
Determines if the current runtime environment is a browser
isBrowser()
// Returns => true
Returns the current URL without any parameters
getBaseUrl('https://google.com/search?query=what')
// Returns => https://google.com/search
Function decodes a Uniform Resource Identifier (URI) component previously created by decodeURIComponent or by a similar routine
decodeUrl("https://google.com/?q=hwewer+erer+re")
// Returns => https://google.com/?q=hwewer%20erer%20re
Function encodes a Uniform Resource Identifier (URI) component previously created by decodeURIComponent or by a similar routine
decodeUrl("https://google.com/?q=hwewer+erer+re")
// Returns => https://google.com/%3Fq%3Dhwewer%2Berer%2Bre
Returns an object
containing the parameters of the URL
getUrlParameters("https://ready.com/green?read=tour&green=tea")
// Returns => {"read":"tour","green":"tea"}
Returns an object
containing the pathname of the URL
getUrlParameters("https://ready.com/green/yellow")
// Returns => {"0":"green","1":"yellow"}
Returns pathname with a regex
exec function see file
getPathname("https://ready.com/green/yellow")
// Returns => "/green/yellow"
Join all given URL
segments together, then normalizes the resulting URL
joinUrl('https://ready.com/green/yellow', 'a', '/r/t', '?foo=barr')
// Returns => "https://ready.com/green/yellow/a/r/t?foo=barr"
Return pathname if parameter is passed or uses the one in the current window
environment.
getWindowPathname() getWindowPathname('http://google.com/red/green/yellow')
// Returns => "/" // Returns => "/red/green/yellow"
Return host if parameter is passed or uses the one in the current window
environment.
getWindowHost() getWindowHost('http://google.com/red/green/yellow')
// Returns => "urley.netlify.app" // Returns => "google.com"
Return hostname if parameter is passed or uses the one in the current window
environment.
getWindowHostName() getWindowHostName('http://google.com/red/green/yellow')
// Returns => "urley.netlify.app" // Returns => "google.com"
Return hash if parameter is passed or uses the one in the current window
environment.
getWindowHash() getWindowHash('http://google.com/red/green/yellow#read')
// Returns => "" // Returns => "#read"
Return href if parameter is passed or uses the one in the current window
environment.
getWindowHref() getWindowHref('http://google.com/red/green/yellow#read')
// Returns => "https://urley.netlify.app/" // Returns => "http://google.com/red/green/yellow#read"
Return port if parameter is passed or uses the one in the current window
environment.
getWindowPort() getWindowPort('http://google.com/red/green/yellow#read')
// Returns => "" // Returns => "3000"
Return protocol if parameter is passed or uses the one in the current window
environment.
getWindowProtocol() getWindowProtocol('http://google.com/red/green/yellow#read')
// Returns => "https:" // Returns => "http:"
Return search strings if parameter is passed or uses the one in the current window
environment.
getWindowSearch() getWindowSearch('http://google.com/red/green/yellow#read')
// Returns => "" // Returns => "?rerer"