window.locationworks fine, but returns me the whole, absolute path, like http://domain.xyz/punch/lines. But I only need http://domain.xyz/
window.location
http://domain.xyz/punch/lines
http://domain.xyz/
I think it will ok for you
var base_url = window.location.origin; var host = window.location.host; var pathArray = window.location.pathname.split( '/' );