From 9294410a19e015898ae637e4f20bf4d55280b979 Mon Sep 17 00:00:00 2001 From: Adriaan <1079135+adriaandotcom@users.noreply.github.com> Date: Tue, 29 Jul 2025 15:36:14 +0200 Subject: [PATCH] fix allowParams regex to be case insensitive --- dist/latest/latest.dev.js | 4 ++-- src/default.js | 2 +- test/unit/pageview-query.test.js | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/dist/latest/latest.dev.js b/dist/latest/latest.dev.js index 17543b8..5bfaa04 100644 --- a/dist/latest/latest.dev.js +++ b/dist/latest/latest.dev.js @@ -1,4 +1,4 @@ -/* Simple Analytics - Privacy-first analytics (docs.simpleanalytics.com/script; 2025-06-24; 80f5; v12) */ +/* Simple Analytics - Privacy-first analytics (docs.simpleanalytics.com/script; 2025-07-29; 9107; v12) */ /* eslint-env browser */ (function ( @@ -244,7 +244,7 @@ // The prefix "utm_" is optional with "strictUtm" disabled // "ref" is only collected when "strictUtm" is disabled - return new RegExp(regex).test(keyValue); + return new RegExp(regex, "i").test(keyValue); }) .join("&") || undefinedVar ); diff --git a/src/default.js b/src/default.js index 2b4e925..4837fba 100644 --- a/src/default.js +++ b/src/default.js @@ -271,7 +271,7 @@ // The prefix "utm_" is optional with "strictUtm" disabled // "ref" is only collected when "strictUtm" is disabled - return new RegExp(regex).test(keyValue); + return new RegExp(regex, "i").test(keyValue); }) .join("&") || undefinedVar ); diff --git a/test/unit/pageview-query.test.js b/test/unit/pageview-query.test.js index 0f4478d..363641d 100644 --- a/test/unit/pageview-query.test.js +++ b/test/unit/pageview-query.test.js @@ -19,4 +19,22 @@ describe("pageview query", function () { done(); }, 10); }); + + it("matches allowed params case insensitively", function (done) { + const dom = createDOM({ + settings: { autoCollect: false, allowParams: "foo" }, + }); + + dom.window.sa_pageview("/manual?FOO=bar"); + + setTimeout(() => { + const req = dom.sent.find( + (r) => r.type === "image" && /path=%2Fmanual/.test(r.url) + ); + expect(req, "pageview request").to.exist; + const url = new URL(req.url); + expect(url.searchParams.get("query")).to.equal("FOO=bar"); + done(); + }, 10); + }); });