Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(@angular/ssr): remove stateful flag from URL_PARAMETER_REGEXP
Removes the stateful `/g` flag from `URL_PARAMETER_REGEXP`. Previously, calling `.test()` on the global regular expression advanced its internal `lastIndex` property. This caused subsequent evaluations in the route extraction pipeline to silently fail to match, skipping `getPrerenderParams` for parameterized routes.

Closes #33154
  • Loading branch information
alan-agius4 committed May 12, 2026
commit d95d4778955954b2246e506b1a910099ca8e3fcf
11 changes: 8 additions & 3 deletions packages/angular/ssr/src/routes/ng-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,14 @@ const MODULE_PRELOAD_MAX = 10;
const CATCH_ALL_REGEXP = /\/(\*\*)$/;

/**
* Regular expression to match segments preceded by a colon in a string.
* Regular expression to match a segment preceded by a colon in a string.
*/
const URL_PARAMETER_REGEXP = /(?<!\\):([^/]+)/g;
const URL_PARAMETER_REGEXP = /(?<!\\):([^/]+)/;
Comment thread
alan-agius4 marked this conversation as resolved.

/**
* Regular expression to match all segments preceded by a colon in a string.
*/
const URL_PARAMETER_GLOBAL_REGEXP = new RegExp(URL_PARAMETER_REGEXP, 'g');

/**
* Additional metadata for a server configuration route tree.
Expand Down Expand Up @@ -464,7 +469,7 @@ async function* handleSSGRoute(
for (const params of parameters) {
const replacer = handlePrerenderParamsReplacement(params, currentRoutePath);
const routeWithResolvedParams = currentRoutePath
.replace(URL_PARAMETER_REGEXP, replacer)
.replace(URL_PARAMETER_GLOBAL_REGEXP, replacer)
.replace(CATCH_ALL_REGEXP, replacer);

yield {
Expand Down
Loading