Skip to content

Commit 9a67ed0

Browse files
committed
Remove cache busting prefix from pixel live URL when validating
1 parent d03e9d1 commit 9a67ed0

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/params_validator.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ export class ParamsValidator {
140140

141141
const urlSplit = url.split('/')[2].split('?');
142142
const livePixelName = urlSplit[0].replaceAll('_', '.');
143-
const livePixelRequestParams = urlSplit[1];
143+
// grab pixel parameters with any preciding cache buster removed
144+
const livePixelRequestParams = /^([0-9]+&)?(.*)$/.exec(urlSplit[1] || '')[2];
144145

145146
// 1) Validate pixel name if it's parameterized
146147
if (livePixelName.length > prefix.length) {

tests/live_pixel_validation_test.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ describe('No common params nor suffixes', () => {
4646
const expectedErrors = ["must NOT have additional properties. Found extra property 'param2'"];
4747
expect(errors).to.have.members(expectedErrors);
4848
});
49+
50+
it('ignores cache buster', () => {
51+
const prefix = 'simplePixel';
52+
const url = `/t/${prefix}?12345&param1=true`;
53+
const errors = paramsValidator.validateLivePixels(pixelDefs[prefix], prefix, url);
54+
expect(errors).to.be.empty;
55+
});
4956
});
5057

5158
describe('Common params', () => {

0 commit comments

Comments
 (0)