Skip to content

Commit c869bb0

Browse files
Merge pull request #81 from simpleanalytics/codex/make-allow-params-regex-case-insensitive
Fix allowParams case sensitivity
2 parents dc116ae + 9294410 commit c869bb0

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

dist/latest/latest.dev.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Simple Analytics - Privacy-first analytics (docs.simpleanalytics.com/script; 2025-06-24; 80f5; v12) */
1+
/* Simple Analytics - Privacy-first analytics (docs.simpleanalytics.com/script; 2025-07-29; 9107; v12) */
22
/* eslint-env browser */
33

44
(function (
@@ -244,7 +244,7 @@
244244

245245
// The prefix "utm_" is optional with "strictUtm" disabled
246246
// "ref" is only collected when "strictUtm" is disabled
247-
return new RegExp(regex).test(keyValue);
247+
return new RegExp(regex, "i").test(keyValue);
248248
})
249249
.join("&") || undefinedVar
250250
);

src/default.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@
271271

272272
// The prefix "utm_" is optional with "strictUtm" disabled
273273
// "ref" is only collected when "strictUtm" is disabled
274-
return new RegExp(regex).test(keyValue);
274+
return new RegExp(regex, "i").test(keyValue);
275275
})
276276
.join("&") || undefinedVar
277277
);

test/unit/pageview-query.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,22 @@ describe("pageview query", function () {
1919
done();
2020
}, 10);
2121
});
22+
23+
it("matches allowed params case insensitively", function (done) {
24+
const dom = createDOM({
25+
settings: { autoCollect: false, allowParams: "foo" },
26+
});
27+
28+
dom.window.sa_pageview("/manual?FOO=bar");
29+
30+
setTimeout(() => {
31+
const req = dom.sent.find(
32+
(r) => r.type === "image" && /path=%2Fmanual/.test(r.url)
33+
);
34+
expect(req, "pageview request").to.exist;
35+
const url = new URL(req.url);
36+
expect(url.searchParams.get("query")).to.equal("FOO=bar");
37+
done();
38+
}, 10);
39+
});
2240
});

0 commit comments

Comments
 (0)