document.location.origin only exsits in Chrome; use pathname instead