diff --git a/src/components/withEnvironment.js b/src/components/withEnvironment.js index f91dd4b533d2..f9a0cf1fa964 100644 --- a/src/components/withEnvironment.js +++ b/src/components/withEnvironment.js @@ -7,6 +7,9 @@ import getComponentDisplayName from '../libs/getComponentDisplayName'; const environmentPropTypes = { /** The string value representing the current environment */ environment: PropTypes.string.isRequired, + + /** The string value representing the URL of the current environment */ + environmentURL: PropTypes.string.isRequired, }; export default function (WrappedComponent) { @@ -16,6 +19,7 @@ export default function (WrappedComponent) { this.state = { environment: CONST.ENVIRONMENT.PRODUCTION, + environmentURL: CONST.NEW_EXPENSIFY_URL, }; } @@ -23,6 +27,9 @@ export default function (WrappedComponent) { Environment.getEnvironment().then((environment) => { this.setState({environment}); }); + Environment.getEnvironmentURL().then((environmentURL) => { + this.setState({environmentURL}); + }); } render() { @@ -32,6 +39,7 @@ export default function (WrappedComponent) { {...this.props} ref={this.props.forwardedRef} environment={this.state.environment} + environmentURL={this.state.environmentURL} /> ); } diff --git a/src/pages/ShareCodePage.js b/src/pages/ShareCodePage.js index ef17f1d474fc..080d9b840bda 100644 --- a/src/pages/ShareCodePage.js +++ b/src/pages/ShareCodePage.js @@ -19,6 +19,8 @@ import CONST from '../CONST'; import ContextMenuItem from '../components/ContextMenuItem'; import * as UserUtils from '../libs/UserUtils'; import ROUTES from '../ROUTES'; +import withEnvironment, {environmentPropTypes} from '../components/withEnvironment'; +import * as Url from '../libs/Url'; const propTypes = { /** The report currently being looked at */ @@ -26,6 +28,7 @@ const propTypes = { ...withLocalizePropTypes, ...withCurrentUserPersonalDetailsPropTypes, + ...environmentPropTypes, }; const defaultProps = { @@ -41,9 +44,10 @@ class ShareCodePage extends React.Component { const isReport = this.props.report != null && this.props.report.reportID != null; const subtitle = ReportUtils.getChatRoomSubtitle(this.props.report); + const urlWithTrailingSlash = Url.addTrailingForwardSlash(this.props.environmentURL); const url = isReport - ? `${CONST.NEW_EXPENSIFY_URL}${ROUTES.getReportRoute(this.props.report.reportID)}` - : `${CONST.NEW_EXPENSIFY_URL}${ROUTES.getProfileRoute(this.props.session.accountID)}`; + ? `${urlWithTrailingSlash}${ROUTES.getReportRoute(this.props.report.reportID)}` + : `${urlWithTrailingSlash}${ROUTES.getProfileRoute(this.props.session.accountID)}`; const platform = getPlatform(); const isNative = platform === CONST.PLATFORM.IOS || platform === CONST.PLATFORM.ANDROID; @@ -96,4 +100,4 @@ class ShareCodePage extends React.Component { ShareCodePage.propTypes = propTypes; ShareCodePage.defaultProps = defaultProps; -export default compose(withLocalize, withCurrentUserPersonalDetails)(ShareCodePage); +export default compose(withEnvironment, withLocalize, withCurrentUserPersonalDetails)(ShareCodePage);