From a0cf4b293074268604b53d5a8481e21b28206d2b Mon Sep 17 00:00:00 2001 From: John Lee Date: Tue, 14 Jun 2022 10:38:11 -0400 Subject: [PATCH] Do not append & to internal Expenisfy URLs that have a # symbol. --- src/libs/actions/Link.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/Link.js b/src/libs/actions/Link.js index 83503f10372..3cc666f0ffb 100644 --- a/src/libs/actions/Link.js +++ b/src/libs/actions/Link.js @@ -39,7 +39,11 @@ function openOldDotLink(url) { } function buildOldDotURL({shortLivedAuthToken}) { - return `${CONFIG.EXPENSIFY.EXPENSIFY_URL}${url}${url.indexOf('?') === -1 ? '?' : '&'}authToken=${shortLivedAuthToken}&email=${encodeURIComponent(currentUserEmail)}`; + const hasHashParams = url.indexOf('#') !== -1; + const hasURLParams = url.indexOf('?') !== -1; + + // If the URL contains # or ?, we can assume they don't need to have the `?` token to start listing url parameters. + return `${CONFIG.EXPENSIFY.EXPENSIFY_URL}${url}${hasHashParams || hasURLParams ? '&' : '?'}authToken=${shortLivedAuthToken}&email=${encodeURIComponent(currentUserEmail)}`; } asyncOpenURL(DeprecatedAPI.GetShortLivedAuthToken(), buildOldDotURL);