mirror of https://github.com/jitsi/jitsi-meet
parent
c4468cb7b8
commit
6a9e6db3be
@ -0,0 +1,37 @@ |
|||||||
|
// @flow
|
||||||
|
|
||||||
|
import { parseStandardURIString } from '../base/util'; |
||||||
|
|
||||||
|
/** |
||||||
|
* Normalizes a URL entered by the user. |
||||||
|
* FIXME: Consider adding this to base/util/uri. |
||||||
|
* |
||||||
|
* @param {string} url - The URL to validate. |
||||||
|
* @returns {string|null} - The normalized URL, or null if the URL is invalid. |
||||||
|
*/ |
||||||
|
export function normalizeUserInputURL(url: string) { |
||||||
|
/* eslint-disable no-param-reassign */ |
||||||
|
|
||||||
|
if (url) { |
||||||
|
url = url.replace(/\s/g, '').toLowerCase(); |
||||||
|
const urlRegExp = new RegExp('^(\\w+://)?(.+)$'); |
||||||
|
const urlComponents = urlRegExp.exec(url); |
||||||
|
|
||||||
|
if (!urlComponents[1] || !urlComponents[1].startsWith('http')) { |
||||||
|
url = `https://${urlComponents[2]}`; |
||||||
|
} |
||||||
|
|
||||||
|
const parsedURI |
||||||
|
= parseStandardURIString(url); |
||||||
|
|
||||||
|
if (!parsedURI.host) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
return parsedURI.toString(); |
||||||
|
} |
||||||
|
|
||||||
|
return url; |
||||||
|
|
||||||
|
/* eslint-enable no-param-reassign */ |
||||||
|
} |
@ -1,22 +0,0 @@ |
|||||||
// @flow
|
|
||||||
|
|
||||||
import { isIPhoneX, Platform } from '../base/react'; |
|
||||||
|
|
||||||
const IPHONE_OFFSET = 20; |
|
||||||
const IPHONEX_OFFSET = 44; |
|
||||||
|
|
||||||
/** |
|
||||||
* Determines the offset to be used for the device. This uses a custom |
|
||||||
* implementation to minimize empty area around screen, especially on iPhone X. |
|
||||||
* |
|
||||||
* @returns {number} |
|
||||||
*/ |
|
||||||
export function getSafetyOffset() { |
|
||||||
if (Platform.OS === 'android') { |
|
||||||
// Android doesn't need offset, except the Essential phone. Should be
|
|
||||||
// addressed later with a generic solution.
|
|
||||||
return 0; |
|
||||||
} |
|
||||||
|
|
||||||
return isIPhoneX() ? IPHONEX_OFFSET : IPHONE_OFFSET; |
|
||||||
} |
|
Loading…
Reference in new issue