Ver código fonte

uri: avoid using String.prototype.normalize

It crashes on Android. Well, on the JSC version React Native uses on Android.

While we could use this fallback only on Android, we have decided to use it
on all mobile platforms for consistency.
master
Saúl Ibarra Corretgé 6 anos atrás
pai
commit
191e530071

+ 6
- 0
package-lock.json Ver arquivo

17595
       "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
17595
       "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
17596
       "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg=="
17596
       "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg=="
17597
     },
17597
     },
17598
+    "unorm": {
17599
+      "version": "1.6.0",
17600
+      "resolved": "https://registry.npmjs.org/unorm/-/unorm-1.6.0.tgz",
17601
+      "integrity": "sha512-b2/KCUlYZUeA7JFUuRJZPUtr4gZvBh7tavtv4fvk4+KV9pfGiR6CQAQAWl49ZpR3ts2dk4FYkP7EIgDJoiOLDA==",
17602
+      "dev": true
17603
+    },
17598
     "unpipe": {
17604
     "unpipe": {
17599
       "version": "1.0.0",
17605
       "version": "1.0.0",
17600
       "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
17606
       "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",

+ 1
- 0
package.json Ver arquivo

126
     "precommit-hook": "3.0.0",
126
     "precommit-hook": "3.0.0",
127
     "string-replace-loader": "2.1.1",
127
     "string-replace-loader": "2.1.1",
128
     "style-loader": "0.19.0",
128
     "style-loader": "0.19.0",
129
+    "unorm": "1.6.0",
129
     "webpack": "4.27.1",
130
     "webpack": "4.27.1",
130
     "webpack-bundle-analyzer": "3.4.1",
131
     "webpack-bundle-analyzer": "3.4.1",
131
     "webpack-cli": "3.1.2",
132
     "webpack-cli": "3.1.2",

+ 14
- 0
react/features/base/util/strings.native.js Ver arquivo

1
+// @flow
2
+
3
+import * as unorm from 'unorm';
4
+
5
+/**
6
+ * Applies NFKC normalization to the given text.
7
+ * NOTE: Here we use the unorm package because the JSC version in React Native for Android crashes.
8
+ *
9
+ * @param {string} text - The text that needs to be normalized.
10
+ * @returns {string} - The normalized text.
11
+ */
12
+export function normalizeNFKC(text: string) {
13
+    return unorm.nfkc(text);
14
+}

+ 11
- 0
react/features/base/util/strings.web.js Ver arquivo

1
+// @flow
2
+
3
+/**
4
+ * Applies NFKC normalization to the given text.
5
+ *
6
+ * @param {string} text - The text that needs to be normalized.
7
+ * @returns {string} - The normalized text.
8
+ */
9
+export function normalizeNFKC(text: string) {
10
+    return text.normalize('NFKC');
11
+}

+ 4
- 2
react/features/base/util/uri.js Ver arquivo

1
 // @flow
1
 // @flow
2
 
2
 
3
+import { normalizeNFKC } from './strings';
4
+
3
 /**
5
 /**
4
  * The app linking scheme.
6
  * The app linking scheme.
5
  * TODO: This should be read from the manifest files later.
7
  * TODO: This should be read from the manifest files later.
120
         // But in this case we're fine goin on...
122
         // But in this case we're fine goin on...
121
     }
123
     }
122
 
124
 
123
-    // Normalize the character set
124
-    room = room.normalize('NFKC');
125
+    // Normalize the character set.
126
+    room = normalizeNFKC(room);
125
 
127
 
126
     // Only decoded and normalized strings can be lowercased properly.
128
     // Only decoded and normalized strings can be lowercased properly.
127
     room = room.toLowerCase();
129
     room = room.toLowerCase();

Carregando…
Cancelar
Salvar