Skip to content

[nextjs] Skip malformed redirect regex rules instead of failing entire redirect chain#537

Open
sc-shakyawijerathne wants to merge 2 commits into
devfrom
bugfix/JSS-9589-malformed-regular-expression-missbehvior
Open

[nextjs] Skip malformed redirect regex rules instead of failing entire redirect chain#537
sc-shakyawijerathne wants to merge 2 commits into
devfrom
bugfix/JSS-9589-malformed-regular-expression-missbehvior

Conversation

@sc-shakyawijerathne

Copy link
Copy Markdown
Contributor

Description / Motivation

Fixes an issue where a single malformed regex in a Sitecore Redirect Map could prevent all redirects in that set from working.

When a redirect pattern was invalid (e.g. an unmatched parenthesis), regex compilation threw an error and aborted the entire redirect evaluation. Valid rules in the same Redirect Map were never reached.

This change safely compiles each redirect pattern, logs a warning for invalid rules, skips them, and continues evaluating the remaining rules.

Testing Details

  • Unit Test Added
  • Manual Test/Other (Please elaborate)

Added regression tests in redirects-proxy.test.ts covering:

  • Malformed regex before a valid static redirect rule
  • Malformed regex before a valid capture-group redirect rule

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

@changeset-bot

changeset-bot Bot commented Jun 25, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4e2659a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sitecore-content-sdk/nextjs Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

📦 Package Size and Test Coverage Report

Package Base Size PR Size Δ Change Base Coverage PR Coverage Δ Change
analytics-core 67.34 KB 67.34 KB ✅ 0.00 KB 97.40% 97.40% 0.00%
cli 61.06 KB 61.06 KB ✅ 0.00 KB 71.36% 71.36% 0.00%
content 432.99 KB 432.99 KB ✅ 0.00 KB 92.46% 92.46% 0.00%
core 120.61 KB 120.61 KB ✅ 0.00 KB 91.27% 91.27% 0.00%
create-content-sdk-app 535.55 KB 535.55 KB ✅ 0.00 KB 96.47% 96.47% 0.00%
events 72.27 KB 72.27 KB ✅ 0.00 KB 97.97% 97.97% 0.00%
nextjs 566.30 KB 569.19 KB 🔺 +2.89 KB 90.99% 91.01% +0.02%
personalize 64.01 KB 64.01 KB ✅ 0.00 KB 99.74% 99.74% 0.00%
react 232.23 KB 232.23 KB ✅ 0.00 KB 94.00% 94.00% 0.00%
search 8.10 KB 8.10 KB ✅ 0.00 KB 98.57% 98.57% 0.00%
Total 🔺 +2.89 KB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant