Problem
The logic that joins a dynamic-route base path with its suffix — special-casing a root base (/) so the two aren't concatenated into a //-prefixed (protocol-relative) path — is duplicated in several places in the navigation layer:
Each site independently does base === '/' ? \/${suffix}` : `${base}/${suffix}`. Because this same rule lives in multiple places, it's easy for one copy to drift or be forgotten — which is exactly what caused the SecurityError: Failed to execute 'pushState'crash fixed in Expensify/App#97849 (thegetPathFromStatecopy was missing the root-base guard and produced//ai-features-promo`).
Proposed change
Extract a small shared helper (e.g. joinPathSegments(base, suffix)) that returns the correctly-adjusted path, and use it at every site above so the slash-normalization rule is defined once.
Note
This came out of a NAB review comment on the fix PR: #97849 (comment)
NAB: Maybe we can extract a helper to return an adjusted path. I see that this logic is repeated elsewhere in the code
Follow-up to #97849.
Issue Owner
Current Issue Owner: @collectioneur
Problem
The logic that joins a dynamic-route base path with its suffix — special-casing a root base (
/) so the two aren't concatenated into a//-prefixed (protocol-relative) path — is duplicated in several places in the navigation layer:src/libs/Navigation/helpers/getPathFromState.ts:170src/libs/Navigation/helpers/getPathFromState.ts:144src/libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute.ts:53Each site independently does
base === '/' ? \/${suffix}` : `${base}/${suffix}`. Because this same rule lives in multiple places, it's easy for one copy to drift or be forgotten — which is exactly what caused theSecurityError: Failed to execute 'pushState'crash fixed in Expensify/App#97849 (thegetPathFromStatecopy was missing the root-base guard and produced//ai-features-promo`).Proposed change
Extract a small shared helper (e.g.
joinPathSegments(base, suffix)) that returns the correctly-adjusted path, and use it at every site above so the slash-normalization rule is defined once.Note
This came out of a NAB review comment on the fix PR: #97849 (comment)
Follow-up to #97849.
Issue Owner
Current Issue Owner: @collectioneur