fix(@angular/ssr): remove stateful flag from URL_PARAMETER_REGEXP#33159
Conversation
There was a problem hiding this comment.
Code Review
This pull request modifies URL_PARAMETER_REGEXP by removing its global flag and updates handleSSGRoute to use a new global RegExp instance for replacements. The reviewer noted that removing the global flag from the constant could cause issues in other functions like resolveRedirectTo which expect global replacement. Additionally, creating a new RegExp instance inside a loop is inefficient; it is recommended to define a separate global constant for the regex to improve performance and maintain consistency.
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 angular#33154
|
This pull request has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Removes the stateful
/gflag fromURL_PARAMETER_REGEXP. Previously, calling.test()on the global regular expression advanced its internallastIndexproperty. This caused subsequent evaluations in the route extraction pipeline to silently fail to match, skippinggetPrerenderParamsfor parameterized routes.Closes #33154