From 6b2faa00f50700a90729d30a0a56a11eb8f5eff5 Mon Sep 17 00:00:00 2001 From: Richard Kettelerij <291572+rkettelerij@users.noreply.github.com> Date: Mon, 6 Jan 2025 17:39:21 +0100 Subject: [PATCH] fix: code scanning alert no. 1: Incomplete URL substring sanitization Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- tests/cypress/support/commands.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/cypress/support/commands.ts b/tests/cypress/support/commands.ts index 74ae01e0..3c7555cd 100644 --- a/tests/cypress/support/commands.ts +++ b/tests/cypress/support/commands.ts @@ -49,8 +49,12 @@ declare global { Cypress.Commands.add('checkForBrokenLinks', () =>{ cy.get('a').each(link => { const href = link.prop('href') - if (href && !href.includes('example.com') && !href.includes('europa.eu')) { - cy.request(href) + if (href) { + const host = new URL(href).host; + const allowedHosts = ['example.com', 'europa.eu']; + if (!allowedHosts.includes(host)) { + cy.request(href) + } } }) })