Updated encoding logic in tracker and send.

This commit is contained in:
Mike Cao 2024-03-26 21:46:57 -07:00
parent 4ee7deafdd
commit 91f49ba506
2 changed files with 30 additions and 8 deletions

View file

@ -32,6 +32,20 @@
/* Helper functions */
const encode = str => {
try {
const result = decodeURI(str);
if (result !== str) {
return result;
}
} catch {
return str;
}
return encodeURI(str);
};
const parseURL = url => {
return excludeSearch ? url.split('?')[0] : url;
};
@ -41,9 +55,9 @@
hostname,
screen,
language,
title: encodeURIComponent(title),
url: encodeURI(currentUrl),
referrer: encodeURI(currentRef),
title: encode(title),
url: encode(currentUrl),
referrer: encode(currentRef),
});
/* Event handlers */