Chrome Extension

Javascript getAbsolutePath

//Javascript get current url 
function getAbsolutePath() {
    var loc = window.location;
    var pathName = loc.pathname.substring(0, loc.pathname.lastIndexOf('/') + 1);
    return loc.href.substring(0, loc.href.length - ((loc.pathname + loc.search + loc.hash).length - pathName.length));
}
Output
"https://gist.github.com/"

Get Current Url Path With Javascript

Search history ×