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.
*
* @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<string> | 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<string> | 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();

View File

@ -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