Skip to content

Commit 81e5111

Browse files
committed
Strengthen skip patterns and fix regex state handling
1 parent 6fe3378 commit 81e5111

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/support/steps/broken-links.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Then('WP Rocket settings links are not broken', async function (this: ICustomWor
6767
}
6868

6969
// Validate all collected URLs, excluding URLs that may trigger transactional side effects
70-
const skipPatterns = [/\/renew\//i, /\/upgrade\//i, /\/express-checkout/i];
70+
const skipPatterns = [/\/renew(?:\/|$|\?)/i, /\/upgrade(?:\/|$|\?)/i, /\/express-checkout(?:\/|$|\?)/i];
7171
const brokenLinks = await validateLinks(this.page, normalizedUrls, currentHost, skipPatterns);
7272

7373
// Report all broken links at once

utils/helpers.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,11 @@ export const validateLinks = async (
662662

663663
for (const url of urls) {
664664
// Skip URLs matching any skip pattern
665-
if (skipPatterns.some(pattern => pattern.test(url))) {
665+
if (skipPatterns.some((pattern: RegExp): boolean => {
666+
// Ensure global/sticky regexes don't carry state between tests
667+
pattern.lastIndex = 0;
668+
return pattern.test(url);
669+
})) {
666670
continue;
667671
}
668672
try {

0 commit comments

Comments
 (0)