Skip to content

Commit 7727ee6

Browse files
Fix code scanning alert no. 16: Incomplete URL substring sanitization
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 4fc2568 commit 7727ee6

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)