Skip to content

Commit 022f5c2

Browse files
authored
Merge pull request #134 from digital-analytics-program/autofix/alert-16-3e11a2f4b9
Fix code scanning alert no. 16: Incomplete URL substring sanitization
2 parents 4fc2568 + 7727ee6 commit 022f5c2

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

features/support/step_definitions/browser_steps.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,14 @@ When("I wait {int} seconds", async function (delaySeconds) {
3434
});
3535

3636
Then("there is a GA4 request", function() {
37-
const ga4Request = this.requests.find(request => request.url.includes("https://www.google-analytics.com/g/collect"));
37+
const ga4Request = this.requests.find(request => {
38+
try {
39+
const url = new URL(request.url);
40+
return url.host === "www.google-analytics.com" && url.pathname === "/g/collect";
41+
} catch (e) {
42+
return false;
43+
}
44+
});
3845
expect(ga4Request).to.exist;
3946
});
4047

0 commit comments

Comments
 (0)