Merge pull request #2612 from jitsi/no_protocol_in_intent_uri

feat(UnsupportedMobileBrowser): do not include protocol in the intent
This commit is contained in:
virtuacoplenny 2018-03-15 10:01:31 -07:00 committed by GitHub
commit eb8f34cee8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 7 deletions

View File

@ -25,10 +25,14 @@ const _URI_PATH_PATTERN = '([^?#]*)';
/** /**
* The {@link RegExp} pattern of the protocol of a URI. * 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} * @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. * 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 // hipchat.com
let regex let regex
= new RegExp( = new RegExp(
`^${_URI_PROTOCOL_PATTERN}//hipchat\\.com/video/call/`, `^${URI_PROTOCOL_PATTERN}//hipchat\\.com/video/call/`,
'gi'); 'gi');
let match: Array<string> | null = regex.exec(uri); let match: Array<string> | null = regex.exec(uri);
@ -55,7 +59,7 @@ function _fixURIStringHierPart(uri) {
// enso.me // enso.me
regex regex
= new RegExp( = new RegExp(
`^${_URI_PROTOCOL_PATTERN}//enso\\.me/(?:call|meeting)/`, `^${URI_PROTOCOL_PATTERN}//enso\\.me/(?:call|meeting)/`,
'gi'); 'gi');
match = regex.exec(uri); match = regex.exec(uri);
} }
@ -87,7 +91,7 @@ function _fixURIStringHierPart(uri) {
* @returns {string} * @returns {string}
*/ */
function _fixURIStringScheme(uri: string) { function _fixURIStringScheme(uri: string) {
const regex = new RegExp(`^${_URI_PROTOCOL_PATTERN}+`, 'gi'); const regex = new RegExp(`^${URI_PROTOCOL_PATTERN}+`, 'gi');
const match: Array<string> | null = regex.exec(uri); const match: Array<string> | null = regex.exec(uri);
if (match) { if (match) {
@ -191,7 +195,7 @@ export function parseStandardURIString(str: string) {
str = str.replace(/\s/g, ''); str = str.replace(/\s/g, '');
// protocol // protocol
regex = new RegExp(`^${_URI_PROTOCOL_PATTERN}`, 'gi'); regex = new RegExp(`^${URI_PROTOCOL_PATTERN}`, 'gi');
match = regex.exec(str); match = regex.exec(str);
if (match) { if (match) {
obj.protocol = match[1].toLowerCase(); obj.protocol = match[1].toLowerCase();

View File

@ -6,6 +6,7 @@ import { connect } from 'react-redux';
import { translate, translateToHTML } from '../../base/i18n'; import { translate, translateToHTML } from '../../base/i18n';
import { Platform } from '../../base/react'; import { Platform } from '../../base/react';
import { URI_PROTOCOL_PATTERN } from '../../base/util';
import { DialInSummary } from '../../invite'; import { DialInSummary } from '../../invite';
import HideNotificationBarStyle from './HideNotificationBarStyle'; 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 // appears to be a link with an app-specific scheme, not a Universal
// Link. // Link.
const appScheme = interfaceConfig.MOBILE_APP_SCHEME || 'org.jitsi.meet'; 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({ this.setState({
joinURL joinURL