diff --git a/package-lock.json b/package-lock.json index dcb741f37..ffff81f75 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18607,6 +18607,12 @@ "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" }, + "unorm": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/unorm/-/unorm-1.6.0.tgz", + "integrity": "sha512-b2/KCUlYZUeA7JFUuRJZPUtr4gZvBh7tavtv4fvk4+KV9pfGiR6CQAQAWl49ZpR3ts2dk4FYkP7EIgDJoiOLDA==", + "dev": true + }, "unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", diff --git a/package.json b/package.json index c572180c3..9e5e51189 100644 --- a/package.json +++ b/package.json @@ -125,6 +125,7 @@ "precommit-hook": "3.0.0", "string-replace-loader": "2.1.1", "style-loader": "0.19.0", + "unorm": "1.6.0", "webpack": "4.26.1", "webpack-bundle-analyzer": "3.4.1", "webpack-cli": "3.1.2", diff --git a/react/features/base/util/strings.native.js b/react/features/base/util/strings.native.js new file mode 100644 index 000000000..154e6df50 --- /dev/null +++ b/react/features/base/util/strings.native.js @@ -0,0 +1,14 @@ +// @flow + +import * as unorm from 'unorm'; + +/** + * Applies NFKC normalization to the given text. + * NOTE: Here we use the unorm package because the JSC version in React Native for Android crashes. + * + * @param {string} text - The text that needs to be normalized. + * @returns {string} - The normalized text. + */ +export function normalizeNFKC(text: string) { + return unorm.nfkc(text); +} diff --git a/react/features/base/util/strings.web.js b/react/features/base/util/strings.web.js new file mode 100644 index 000000000..e07c55893 --- /dev/null +++ b/react/features/base/util/strings.web.js @@ -0,0 +1,11 @@ +// @flow + +/** + * Applies NFKC normalization to the given text. + * + * @param {string} text - The text that needs to be normalized. + * @returns {string} - The normalized text. + */ +export function normalizeNFKC(text: string) { + return text.normalize('NFKC'); +} diff --git a/react/features/base/util/uri.js b/react/features/base/util/uri.js index 197b480e7..e114adcb1 100644 --- a/react/features/base/util/uri.js +++ b/react/features/base/util/uri.js @@ -1,5 +1,7 @@ // @flow +import { normalizeNFKC } from './strings'; + /** * The app linking scheme. * TODO: This should be read from the manifest files later. @@ -120,8 +122,8 @@ export function getBackendSafeRoomName(room: ?string): ?string { // But in this case we're fine goin on... } - // Normalize the character set - room = room.normalize('NFKC'); + // Normalize the character set. + room = normalizeNFKC(room); // Only decoded and normalized strings can be lowercased properly. room = room.toLowerCase();