Merge pull request #94 from jnettome/history-state-fix

Fixes tracker code bug on handling pushState
This commit is contained in:
Mike Cao 2020-09-02 14:43:07 -07:00 committed by GitHub
commit 2078005780
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -58,15 +58,15 @@ import { removeTrailingSlash } from '../lib/url';
/* Handle history */ /* Handle history */
const handlePush = (state, title, navaigatedUrl) => { const handlePush = (state, title, navigatedURL) => {
removeEvents(); removeEvents();
currentRef = currentUrl; currentRef = currentUrl;
if (navaigatedUrl.startsWith('http')) { if (navigatedURL.toString().startsWith('http')) {
const url = new URL(navaigatedUrl); const url = new URL(navigatedURL.toString());
currentUrl = `${url.pathname}${url.search}`; currentUrl = `${url.pathname}${url.search}`;
} else { } else {
currentUrl = navaigatedUrl; currentUrl = navigatedURL.toString();
} }
pageView(); pageView();