From 6ae89fc3e95b16767fbd93b12373c7273d09f915 Mon Sep 17 00:00:00 2001 From: Monil Bhavsar Date: Wed, 8 Feb 2023 19:14:19 +0530 Subject: [PATCH 1/5] Update staging URL --- .env.staging | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.staging b/.env.staging index c789087ebded..b94a5fde412d 100644 --- a/.env.staging +++ b/.env.staging @@ -1,6 +1,6 @@ NEW_EXPENSIFY_URL=https://staging.new.expensify.com/ SECURE_EXPENSIFY_URL=https://secure.expensify.com/ -EXPENSIFY_URL=https://www.expensify.com/ +EXPENSIFY_URL=https://staging.expensify.com/ EXPENSIFY_PARTNER_NAME=chat-expensify-com EXPENSIFY_PARTNER_PASSWORD=e21965746fd75f82bb66 PUSHER_APP_KEY=268df511a204fbb60884 From 2e9b031aabb3839b416cfd4e637c134a82ceb902 Mon Sep 17 00:00:00 2001 From: Monil Bhavsar Date: Wed, 15 Feb 2023 17:43:22 +0530 Subject: [PATCH 2/5] Use environment to determine the URL --- src/CONST.js | 3 +++ src/libs/Environment/Environment.js | 19 +++++++++++++++++++ src/libs/actions/Link.js | 21 ++++++++++++++++----- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/CONST.js b/src/CONST.js index 48206b8f9755..3df31e36eb27 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -274,6 +274,9 @@ const CONST = { CFPB_PREPAID_URL: 'https://cfpb.gov/prepaid', STAGING_NEW_EXPENSIFY_URL: 'https://staging.new.expensify.com', NEWHELP_URL: 'https://help.expensify.com', + DEV_EXPENSIFY_URL: 'https://www.expensify.com.dev', + STAGING_EXPENSIFY_URL: 'https://staging.expensify.com', + EXPENSIFY_URL: 'https://www.expensify.com', // Use Environment.getEnvironmentURL to get the complete URL with port number DEV_NEW_EXPENSIFY_URL: 'http://localhost:', diff --git a/src/libs/Environment/Environment.js b/src/libs/Environment/Environment.js index a14300520bb5..5f7311b47a29 100644 --- a/src/libs/Environment/Environment.js +++ b/src/libs/Environment/Environment.js @@ -10,6 +10,12 @@ const ENVIRONMENT_URLS = { [CONST.ENVIRONMENT.PRODUCTION]: CONST.NEW_EXPENSIFY_URL, }; +const OLDDOT_ENVIRONMENT_URLS = { + [CONST.ENVIRONMENT.DEV]: CONST.DEV_EXPENSIFY_URL, + [CONST.ENVIRONMENT.STAGING]: CONST.STAGING_EXPENSIFY_URL, + [CONST.ENVIRONMENT.PRODUCTION]: CONST.EXPENSIFY_URL, +}; + /** * Are we running the app in development? * @@ -31,8 +37,21 @@ function getEnvironmentURL() { }); } +/** + * Get the corresponding oldDot URL based on the environment we are in + * + * @returns {Promise} + */ +function getOldDotEnvironmentURL() { + return new Promise((resolve) => { + getEnvironment() + .then(environment => resolve(OLDDOT_ENVIRONMENT_URLS[environment])); + }); +} + export { getEnvironment, isDevelopment, getEnvironmentURL, + getOldDotEnvironmentURL, }; diff --git a/src/libs/actions/Link.js b/src/libs/actions/Link.js index bb978b331e20..7ba6c1501532 100644 --- a/src/libs/actions/Link.js +++ b/src/libs/actions/Link.js @@ -9,6 +9,8 @@ import CONST from '../../CONST'; import CONFIG from '../../CONFIG'; import asyncOpenURL from '../asyncOpenURL'; import * as API from '../API'; +import * as Environment from '../Environment/Environment'; +import * as Url from '../Url'; let isNetworkOffline = false; Onyx.connect({ @@ -38,7 +40,7 @@ function showGrowlIfOffline() { function openOldDotLink(url) { /** * @param {String} [shortLivedAuthToken] - * @returns {String} + * @returns {Promise } */ function buildOldDotURL(shortLivedAuthToken) { const hasHashParams = url.indexOf('#') !== -1; @@ -49,8 +51,13 @@ function openOldDotLink(url) { const params = _.compact([authTokenParam, emailParam]).join('&'); - // 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 ? '&' : '?'}${params}`; + return Environment.getOldDotEnvironmentURL() + .then((environmentURL) => { + const oldDotDomain = Url.addTrailingForwardSlash(environmentURL || CONFIG.EXPENSIFY.EXPENSIFY_URL); + + // If the URL contains # or ?, we can assume they don't need to have the `?` token to start listing url parameters. + return `${oldDotDomain}${url}${hasHashParams || hasURLParams ? '&' : '?'}${params}`; + }); } if (isNetworkOffline) { @@ -63,9 +70,13 @@ function openOldDotLink(url) { API.makeRequestWithSideEffects( 'OpenOldDotLink', {}, {}, ).then((response) => { - Linking.openURL(buildOldDotURL(response.shortLivedAuthToken)); + buildOldDotURL(response.shortLivedAuthToken).then((oldDotUrl) => { + Linking.openURL(oldDotUrl); + }); }).catch(() => { - Linking.openURL(buildOldDotURL()); + buildOldDotURL().then((oldDotUrl) => { + Linking.openURL(oldDotUrl); + }); }); } From bb0e55bffe48dac74d0f1a87e336ce13ac8bd5b6 Mon Sep 17 00:00:00 2001 From: Monil Bhavsar Date: Mon, 27 Feb 2023 15:26:18 +0530 Subject: [PATCH 3/5] Address reviews --- .env.staging | 2 +- src/libs/Environment/Environment.js | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.env.staging b/.env.staging index b94a5fde412d..c789087ebded 100644 --- a/.env.staging +++ b/.env.staging @@ -1,6 +1,6 @@ NEW_EXPENSIFY_URL=https://staging.new.expensify.com/ SECURE_EXPENSIFY_URL=https://secure.expensify.com/ -EXPENSIFY_URL=https://staging.expensify.com/ +EXPENSIFY_URL=https://www.expensify.com/ EXPENSIFY_PARTNER_NAME=chat-expensify-com EXPENSIFY_PARTNER_PASSWORD=e21965746fd75f82bb66 PUSHER_APP_KEY=268df511a204fbb60884 diff --git a/src/libs/Environment/Environment.js b/src/libs/Environment/Environment.js index 5f7311b47a29..2db6afb11d77 100644 --- a/src/libs/Environment/Environment.js +++ b/src/libs/Environment/Environment.js @@ -40,13 +40,11 @@ function getEnvironmentURL() { /** * Get the corresponding oldDot URL based on the environment we are in * - * @returns {Promise} + * @returns {Promise } */ function getOldDotEnvironmentURL() { - return new Promise((resolve) => { - getEnvironment() - .then(environment => resolve(OLDDOT_ENVIRONMENT_URLS[environment])); - }); + return getEnvironment() + .then(environment => OLDDOT_ENVIRONMENT_URLS[environment]); } export { From 6940a8ac75ac194cb421be1fbb5ca204101a38fa Mon Sep 17 00:00:00 2001 From: Monil Bhavsar Date: Wed, 1 Mar 2023 17:18:56 +0530 Subject: [PATCH 4/5] Address reviews --- src/CONST.js | 2 +- src/libs/Environment/Environment.js | 4 ++-- src/libs/actions/Link.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/CONST.js b/src/CONST.js index e98169f30cc2..5c1b20f1f3db 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -280,7 +280,7 @@ const CONST = { CFPB_PREPAID_URL: 'https://cfpb.gov/prepaid', STAGING_NEW_EXPENSIFY_URL: 'https://staging.new.expensify.com', NEWHELP_URL: 'https://help.expensify.com', - DEV_EXPENSIFY_URL: 'https://www.expensify.com.dev', + INTERNAL_DEV_EXPENSIFY_URL: 'https://www.expensify.com.dev', STAGING_EXPENSIFY_URL: 'https://staging.expensify.com', EXPENSIFY_URL: 'https://www.expensify.com', diff --git a/src/libs/Environment/Environment.js b/src/libs/Environment/Environment.js index 2db6afb11d77..bdba9f20d12d 100644 --- a/src/libs/Environment/Environment.js +++ b/src/libs/Environment/Environment.js @@ -11,7 +11,7 @@ const ENVIRONMENT_URLS = { }; const OLDDOT_ENVIRONMENT_URLS = { - [CONST.ENVIRONMENT.DEV]: CONST.DEV_EXPENSIFY_URL, + [CONST.ENVIRONMENT.DEV]: CONST.INTERNAL_DEV_EXPENSIFY_URL, [CONST.ENVIRONMENT.STAGING]: CONST.STAGING_EXPENSIFY_URL, [CONST.ENVIRONMENT.PRODUCTION]: CONST.EXPENSIFY_URL, }; @@ -40,7 +40,7 @@ function getEnvironmentURL() { /** * Get the corresponding oldDot URL based on the environment we are in * - * @returns {Promise } + * @returns {Promise} */ function getOldDotEnvironmentURL() { return getEnvironment() diff --git a/src/libs/actions/Link.js b/src/libs/actions/Link.js index 7ba6c1501532..097b16e1d276 100644 --- a/src/libs/actions/Link.js +++ b/src/libs/actions/Link.js @@ -40,7 +40,7 @@ function showGrowlIfOffline() { function openOldDotLink(url) { /** * @param {String} [shortLivedAuthToken] - * @returns {Promise } + * @returns {Promise} */ function buildOldDotURL(shortLivedAuthToken) { const hasHashParams = url.indexOf('#') !== -1; @@ -53,7 +53,7 @@ function openOldDotLink(url) { return Environment.getOldDotEnvironmentURL() .then((environmentURL) => { - const oldDotDomain = Url.addTrailingForwardSlash(environmentURL || CONFIG.EXPENSIFY.EXPENSIFY_URL); + const oldDotDomain = Url.addTrailingForwardSlash(environmentURL); // If the URL contains # or ?, we can assume they don't need to have the `?` token to start listing url parameters. return `${oldDotDomain}${url}${hasHashParams || hasURLParams ? '&' : '?'}${params}`; From 5a980d2e93551c62c4269c7a6b9a7cd51a5ba692 Mon Sep 17 00:00:00 2001 From: Monil Bhavsar Date: Wed, 8 Mar 2023 00:23:36 +0530 Subject: [PATCH 5/5] Lint fix --- src/libs/actions/Link.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/actions/Link.js b/src/libs/actions/Link.js index 097b16e1d276..53984be930a5 100644 --- a/src/libs/actions/Link.js +++ b/src/libs/actions/Link.js @@ -6,7 +6,6 @@ import ONYXKEYS from '../../ONYXKEYS'; import Growl from '../Growl'; import * as Localize from '../Localize'; import CONST from '../../CONST'; -import CONFIG from '../../CONFIG'; import asyncOpenURL from '../asyncOpenURL'; import * as API from '../API'; import * as Environment from '../Environment/Environment';