diff --git a/src/CONST.js b/src/CONST.js index f5df1e71d1f2..1981eaff576e 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -2,7 +2,8 @@ import lodashGet from 'lodash/get'; import Config from 'react-native-config'; import * as Url from './libs/Url'; -const CLOUDFRONT_URL = 'https://d2k5nsl2zxldvw.cloudfront.net'; +const CLOUDFRONT_DOMAIN = 'cloudfront.net'; +const CLOUDFRONT_URL = `https://d2k5nsl2zxldvw.${CLOUDFRONT_DOMAIN}`; const ACTIVE_EXPENSIFY_URL = Url.addTrailingForwardSlash(lodashGet(Config, 'NEW_EXPENSIFY_URL', 'https://new.expensify.com')); const USE_EXPENSIFY_URL = 'https://use.expensify.com'; const PLATFORM_OS_MACOS = 'Mac OS'; @@ -296,6 +297,7 @@ const CONST = { GOOGLE_MEET_URL_ANDROID: 'https://meet.google.com', DEEPLINK_BASE_URL: 'new-expensify://', PDF_VIEWER_URL: '/pdf/web/viewer.html', + CLOUDFRONT_DOMAIN_REGEX: /^https:\/\/\w+\.cloudfront\.net/i, EXPENSIFY_ICON_URL: `${CLOUDFRONT_URL}/images/favicon-2019.png`, CONCIERGE_ICON_URL: `${CLOUDFRONT_URL}/images/icons/concierge_2022.png`, UPWORK_URL: 'https://github.com/Expensify/App/issues?q=is%3Aopen+is%3Aissue+label%3A%22Help+Wanted%22', diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 15000bbb87e8..bb07c7d25e34 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -571,6 +571,11 @@ function getSmallSizeAvatar(avatarURL, login) { return source; } + // Because other urls than CloudFront do not support dynamic image sizing (_SIZE suffix), the current source is already what we want to use here. + if (!CONST.CLOUDFRONT_DOMAIN_REGEX.test(source)) { + return source; + } + // If image source already has _128 at the end, the given avatar URL is already what we want to use here. const lastPeriodIndex = source.lastIndexOf('.'); if (source.substring(lastPeriodIndex - 4, lastPeriodIndex) === '_128') {