Skip to content

Commit 52a252a

Browse files
[getsentry/action-github-commit] Auto commit
1 parent 499aa34 commit 52a252a

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

scripts/check-redirects-on-rename.spec.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,19 @@ describe('redirectMatches', () => {
316316
};
317317
// Dot should be treated as literal, not regex "any character"
318318
expect(
319-
redirectMatches(redirect, '/platforms/javascript/guide.old/', '/platforms/javascript/guide.new/')
319+
redirectMatches(
320+
redirect,
321+
'/platforms/javascript/guide.old/',
322+
'/platforms/javascript/guide.new/'
323+
)
320324
).toBe(true);
321325
// Should not match "guidexold" (if dot was treated as regex)
322326
expect(
323-
redirectMatches(redirect, '/platforms/javascript/guidexold/', '/platforms/javascript/guide.new/')
327+
redirectMatches(
328+
redirect,
329+
'/platforms/javascript/guidexold/',
330+
'/platforms/javascript/guide.new/'
331+
)
324332
).toBe(false);
325333
});
326334

@@ -339,7 +347,11 @@ describe('redirectMatches', () => {
339347
).toBe(true);
340348
// Should not match without brackets
341349
expect(
342-
redirectMatches(redirect, '/platforms/javascript/guide/', '/platforms/javascript/guide/')
350+
redirectMatches(
351+
redirect,
352+
'/platforms/javascript/guide/',
353+
'/platforms/javascript/guide/'
354+
)
343355
).toBe(false);
344356
});
345357

scripts/check-redirects-on-rename.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -300,20 +300,20 @@ function convertRedirectPatternToRegex(pattern: string): string {
300300
// then replace placeholders with regex patterns
301301
const placeholderPathStar = '__PATH_STAR_PLACEHOLDER__';
302302
const placeholderParam = '__PARAM_PLACEHOLDER__';
303-
303+
304304
// Replace path parameters with placeholders
305305
let result = pattern
306-
.replace(/:\w+\*/g, placeholderPathStar) // :path* -> placeholder
307-
.replace(/:\w+/g, placeholderParam); // :param -> placeholder
308-
306+
.replace(/:\w+\*/g, placeholderPathStar) // :path* -> placeholder
307+
.replace(/:\w+/g, placeholderParam); // :param -> placeholder
308+
309309
// Escape all special regex characters
310310
result = escapeRegexSpecialChars(result);
311-
311+
312312
// Replace placeholders with regex patterns
313313
result = result
314-
.replace(new RegExp(escapeRegexSpecialChars(placeholderPathStar), 'g'), '.*') // placeholder -> .*
315-
.replace(new RegExp(escapeRegexSpecialChars(placeholderParam), 'g'), '[^/]+'); // placeholder -> [^/]+
316-
314+
.replace(new RegExp(escapeRegexSpecialChars(placeholderPathStar), 'g'), '.*') // placeholder -> .*
315+
.replace(new RegExp(escapeRegexSpecialChars(placeholderParam), 'g'), '[^/]+'); // placeholder -> [^/]+
316+
317317
return result;
318318
}
319319

0 commit comments

Comments
 (0)