Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Properly parse url and respect data-exclude-search attribute in tracker #2679

Merged
10 changes: 8 additions & 2 deletions src/tracker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
document,
history,
} = window;
const { hostname, pathname, search } = location;
const { hostname, href } = location;
const { currentScript, referrer } = document;

if (!currentScript) return;
Expand Down Expand Up @@ -52,6 +52,12 @@
};

const parseURL = url => {
try {
const { pathname, search } = new URL(url);
url = pathname + search;
} catch {
/* empty */
}
return excludeSearch ? url.split('?')[0] : url;
};

Expand Down Expand Up @@ -238,7 +244,7 @@
};
}

let currentUrl = `${pathname}${search}`;
let currentUrl = parseURL(href);
let currentRef = referrer !== hostname ? referrer : '';
let title = document.title;
let cache;
Expand Down