Skip to content

[Refactor] Extract a shared helper for dynamic-route path joining (root-base slash normalization) #98145

Closed

Description

@MelvinBot

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 OwnerCurrent Issue Owner: @collectioneur

Activity

  1. added and removed
    Weekly
    on Sep 3, 2026
  2. melvin-bot commented on Sep 3, 2026

    @melvin-bot

    This issue has not been updated in over 15 days. @mountiny, @collectioneur eroding to Monthly issue.

    P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

  3. mountiny commented on Sep 9, 2026

    @mountiny
    Contributor

    @collectioneur Are you able to follow up on this one?

  4. collectioneur commented on Sep 9, 2026

    @collectioneur
    Contributor

    Sure, I'll prepare a PR for this. Missed that!

  5. added
    Reviewing
    Weekly
    and removed on Sep 9, 2026
  6. collectioneur commented on Sep 9, 2026

    @collectioneur
    Contributor

    Opened the PR

  7. added
    Daily
    and removed
    Reviewing
    Weekly
    on Sep 11, 2026
  8. melvin-bot commented on Sep 11, 2026

    @melvin-bot

    @mountiny @collectioneur

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.4.76-1 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

  9. melvin-bot commented on Sep 14, 2026

    @melvin-bot

    @collectioneur Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  10. collectioneur commented on Sep 15, 2026

    @collectioneur
    Contributor

    Not overdue

  11. mountiny commented on Sep 17, 2026

    @mountiny
    Contributor

    This is done

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

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions