Skip to content

Home

Get base URL

Gets the current URL without any parameters or fragment identifiers.

const getBaseURL = url => url.replace(/[?#].*$/, '');

getBaseURL('http://url.com/page?name=Adam&surname=Smith');
// 'http://url.com/page'

More like this

Start typing a keyphrase to see matching snippets.