Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ea95e1a

Browse filesBrowse files
committed
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 (cherry picked from commit 0fdcde5)
1 parent 3829508 commit ea95e1a
Copy full SHA for ea95e1a

1 file changed

+8-3Lines changed: 8 additions & 3 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/angular/ssr/src/routes/ng-routes.ts‎

Copy file name to clipboardExpand all lines: packages/angular/ssr/src/routes/ng-routes.ts
+8-3Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,14 @@ const MODULE_PRELOAD_MAX = 10;
7474
const CATCH_ALL_REGEXP = /\/(\*\*)$/;
7575

7676
/**
77-
* Regular expression to match segments preceded by a colon in a string.
77+
* Regular expression to match a segment preceded by a colon in a string.
7878
*/
79-
const URL_PARAMETER_REGEXP = /(?<!\\):([^/]+)/g;
79+
const URL_PARAMETER_REGEXP = /(?<!\\):([^/]+)/;
80+
81+
/**
82+
* Regular expression to match all segments preceded by a colon in a string.
83+
*/
84+
const URL_PARAMETER_GLOBAL_REGEXP = new RegExp(URL_PARAMETER_REGEXP, 'g');
8085

8186
/**
8287
* Additional metadata for a server configuration route tree.
@@ -464,7 +469,7 @@ async function* handleSSGRoute(
464469
for (const params of parameters) {
465470
const replacer = handlePrerenderParamsReplacement(params, currentRoutePath);
466471
const routeWithResolvedParams = currentRoutePath
467-
.replace(URL_PARAMETER_REGEXP, replacer)
472+
.replace(URL_PARAMETER_GLOBAL_REGEXP, replacer)
468473
.replace(CATCH_ALL_REGEXP, replacer);
469474

470475
yield {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.