Skip to content

Commit

Permalink
Remove cache busting prefix from pixel live URL when validating
Browse files Browse the repository at this point in the history
  • Loading branch information
sammacbeth committed Jan 10, 2025
1 parent d03e9d1 commit ab2adea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/params_validator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ export class ParamsValidator {

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

// 1) Validate pixel name if it's parameterized
if (livePixelName.length > prefix.length) {
Expand Down
7 changes: 7 additions & 0 deletions tests/live_pixel_validation_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ describe('No common params nor suffixes', () => {
const expectedErrors = ["must NOT have additional properties. Found extra property 'param2'"];
expect(errors).to.have.members(expectedErrors);
});

it('ignores cache buster', () => {
const prefix = 'simplePixel';
const url = `/t/${prefix}?12345&param1=true`;
const errors = paramsValidator.validateLivePixels(pixelDefs[prefix], prefix, url);
expect(errors).to.be.empty;
})
});

describe('Common params', () => {
Expand Down

0 comments on commit ab2adea

Please sign in to comment.