Documentation For Urley

A cross-platform library with a collection of handy utilites to work with URLs

Open Demo In CodeSandbox



Is Absolute


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

Is Browser


Determines if the current runtime environment is a browser

isBrowser()
// Returns => true

Get Base URL


Returns the current URL without any parameters

getBaseUrl('https://google.com/search?query=what')
// Returns => https://google.com/search

Decode URL


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

Encode URL


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

Get URL Parameters


Returns an object containing the parameters of the URL

getUrlParameters("https://ready.com/green?read=tour&green=tea")
// Returns => {"read":"tour","green":"tea"}

Get Pathname To Object


Returns an object containing the pathname of the URL

getUrlParameters("https://ready.com/green/yellow")
// Returns => {"0":"green","1":"yellow"}

Get Path Name


Returns pathname with a regex exec function see file

getPathname("https://ready.com/green/yellow")
// Returns => "/green/yellow"

Join URL


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"

Window Portion


Get Window Path Name

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"
Get Window Host

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"
Get Window Host Name

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"
Get Window Hash

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"
Get Window HREF (Hypertext REFerence)

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"
Get Window Port

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"
Get Window Protocol

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:"
Get Window Search

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"