Repository navigation
97470 normalize path collapse slashes - #100847
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2bbdb94b8f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const queryIndex = path.indexOf('?'); | ||
| const pathOnly = queryIndex === -1 ? path : path.slice(0, queryIndex); | ||
| const query = queryIndex === -1 ? '' : path.slice(queryIndex); |
There was a problem hiding this comment.
Preserve slash pairs inside URL fragments
When a route has a fragment but no query string, such as /home#https://example.com, queryIndex remains -1, so the fragment is included in pathOnly and later normalized to /home#https:/example.com. Fragments are opaque URL data and do not participate in pushState origin resolution; split at the earliest ? or # so only the pathname is collapsed.
Useful? React with 👍 / 👎.
|
@WojtekBoman The PR is ready for review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7ee46315fe
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
|
||
| if (pathOnly.includes('//')) { | ||
| // The query and fragment are excluded because they can carry data we shouldn't ship. | ||
| Log.alert('[Navigation] normalizePath received a malformed path', {path: pathOnly}); |
There was a problem hiding this comment.
Redact credentials from malformed paths before alerting
When a malformed validation or unlink link such as //v/<accountID>/<validateCode> is normalized, this alert includes the raw validation code in path; Log.alert uploads its payload to the logging backend and Sentry. These codes are explicitly classified as sensitive, and sanitizeUrlForLogging() already redacts the /v/ and /u/ route segments, so sanitize this value before logging it (or omit the path entirely) to avoid exposing login credentials whenever such a link contains repeated slashes.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
I've omitted the path entirely
| */ | ||
| function normalizePath(path: string) { | ||
| return !path.startsWith('/') ? `/${path}` : path; | ||
| // Split at the first '?' or '#': only the pathname decides how the browser resolves the origin, |
There was a problem hiding this comment.
Is this sentence finished?
There was a problem hiding this comment.
It should be cleaned up, I missed this change
|
|
||
| if (pathOnly.includes('//')) { | ||
| // The query and fragment are excluded because they can carry data we shouldn't ship. | ||
| Log.alert('[Navigation] normalizePath received a malformed path', {path: pathOnly}); |
There was a problem hiding this comment.
Do we want to track it in Sentry? If so, it will require some configuration in forwardLogsToSentry
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
I think we can skip tracking [Navigation] in Sentry, so we won't need to update FORWARDED_LOG_PREFIXES
WojtekBoman
left a comment
There was a problem hiding this comment.
LGTM! It's worth taking the AI reviewer's comment into account, but besides that the code is good!
I considered adding a fix for pushState as a safeguard, but since this code solves the problem, there’s no need. We can do that if the issue returns (hopefully not 🤞).
Good job!
|
@suneox do I need to review? |
I think no need! @WojtekBoman has already reviewed it |
|
@mountiny All yours! Hopefully, this PR can cover the remaining cases 😄 |
|
@Pujan92 Actually I think it would be good to do extra testing and checklist, can you please check? |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / SafariUploading Screen Recording 2026-09-13 at 19.37.44.mov… |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚧 mountiny has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.4.80-0 🚀
|
|
🤖 No help site changes are required for this PR — no draft docs PR was created. This PR is an internal URL-parsing fix. It collapses repeated slashes in Why nothing in
|
|
🚀 Deployed to production by https://github.com/luacmartins in version: 9.4.80-0 🚀
Bundle Size Analysis (Sentry): |
Explanation of Change
normalizePathonly added the leading/, so a path with repeated slashes passed through untouched. React Navigation keeps that raw input onroute.pathanduseLinkingprefers it overgetPathFromState, so the malformed path was pushed verbatim on the next navigation andhistory.pushStaterejected it - the browser reads//workspaces/…as protocol-relative, makingworkspacesthe host.This collapses repeated slashes in
normalizePathand routesgetStateFromPathandgetAdaptedStateFromPaththrough it, since each carried its own inline copy that only added the leading slash. Only the path is collapsed, never the query, and aLog.alertreports malformed paths that still arrive so we can find where they come from.Fixed Issues
$ #97470
PROPOSAL: #97470 (comment)
Tests
Log.alertwrites throughconsole.debug, which Chrome hides by default.https://dev.new.expensify.com:8082//settings/profile/settings/profile[alrt] [Navigation] normalizePath received a malformed pathwithpath: "//settings/profile", and that no query string appears in that log entryVerify no
SecurityError: Failed to execute 'pushState' on 'History'appears in the consoleVerify that no errors appear in the JS console
Offline tests
Same as tests. Path normalization happens before any network call, so the behavior is identical offline.
QA Steps
Same as tests with staging
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
CleanShot.2026-09-10.at.23.43.21.1.mp4
Android: mWeb Chrome
CleanShot.2026-09-11.at.00.00.29.1.mp4
iOS: Native
CleanShot.2026-09-11.at.00.09.00.3.mp4
iOS: mWeb Safari
CleanShot.2026-09-11.at.00.04.43.2.mp4
MacOS: Chrome / Safari
N/A
MacOS: Desktop
CleanShot.2026-09-10.at.20.25.54.1.mp4