From 40d7d0c9cb075a999e6dfe41042f172d69f94a7e Mon Sep 17 00:00:00 2001 From: paweldomas Date: Wed, 14 Mar 2018 17:17:49 -0500 Subject: [PATCH] feat(UnsupportedMobileBrowser): do not include protocol in the intent Do not include the protocol part in the intent URL. --- react/features/base/util/uri.js | 16 ++++++++++------ .../components/UnsupportedMobileBrowser.js | 7 ++++++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/react/features/base/util/uri.js b/react/features/base/util/uri.js index 672f945d1..b742dd347 100644 --- a/react/features/base/util/uri.js +++ b/react/features/base/util/uri.js @@ -25,10 +25,14 @@ const _URI_PATH_PATTERN = '([^?#]*)'; /** * The {@link RegExp} pattern of the protocol of a URI. * - * @private + * FIXME: The URL class exposed by JavaScript will not include the colon in + * the protocol field. Also in other places (at the time of this writing: + * the UnsupportedMobileBrowser.js) the APP_LINK_SCHEME does not include + * the double dots, so things are inconsistent. + * * @type {string} */ -const _URI_PROTOCOL_PATTERN = '([a-z][a-z0-9\\.\\+-]*:)'; +export const URI_PROTOCOL_PATTERN = '([a-z][a-z0-9\\.\\+-]*:)'; /** * Fixes the hier-part of a specific URI (string) so that the URI is well-known. @@ -47,7 +51,7 @@ function _fixURIStringHierPart(uri) { // hipchat.com let regex = new RegExp( - `^${_URI_PROTOCOL_PATTERN}//hipchat\\.com/video/call/`, + `^${URI_PROTOCOL_PATTERN}//hipchat\\.com/video/call/`, 'gi'); let match: Array | null = regex.exec(uri); @@ -55,7 +59,7 @@ function _fixURIStringHierPart(uri) { // enso.me regex = new RegExp( - `^${_URI_PROTOCOL_PATTERN}//enso\\.me/(?:call|meeting)/`, + `^${URI_PROTOCOL_PATTERN}//enso\\.me/(?:call|meeting)/`, 'gi'); match = regex.exec(uri); } @@ -87,7 +91,7 @@ function _fixURIStringHierPart(uri) { * @returns {string} */ function _fixURIStringScheme(uri: string) { - const regex = new RegExp(`^${_URI_PROTOCOL_PATTERN}+`, 'gi'); + const regex = new RegExp(`^${URI_PROTOCOL_PATTERN}+`, 'gi'); const match: Array | null = regex.exec(uri); if (match) { @@ -191,7 +195,7 @@ export function parseStandardURIString(str: string) { str = str.replace(/\s/g, ''); // protocol - regex = new RegExp(`^${_URI_PROTOCOL_PATTERN}`, 'gi'); + regex = new RegExp(`^${URI_PROTOCOL_PATTERN}`, 'gi'); match = regex.exec(str); if (match) { obj.protocol = match[1].toLowerCase(); diff --git a/react/features/unsupported-browser/components/UnsupportedMobileBrowser.js b/react/features/unsupported-browser/components/UnsupportedMobileBrowser.js index 644c03ae6..7d0381a39 100644 --- a/react/features/unsupported-browser/components/UnsupportedMobileBrowser.js +++ b/react/features/unsupported-browser/components/UnsupportedMobileBrowser.js @@ -6,6 +6,7 @@ import { connect } from 'react-redux'; import { translate, translateToHTML } from '../../base/i18n'; import { Platform } from '../../base/react'; +import { URI_PROTOCOL_PATTERN } from '../../base/util'; import { DialInSummary } from '../../invite'; import HideNotificationBarStyle from './HideNotificationBarStyle'; @@ -82,7 +83,11 @@ class UnsupportedMobileBrowser extends Component<*, *> { // appears to be a link with an app-specific scheme, not a Universal // Link. const appScheme = interfaceConfig.MOBILE_APP_SCHEME || 'org.jitsi.meet'; - const joinURL = `${appScheme}:${window.location.href}`; + + // Replace the protocol part with the app scheme. + const joinURL + = window.location.href.replace( + new RegExp(`^${URI_PROTOCOL_PATTERN}`), `${appScheme}:`); this.setState({ joinURL