You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-03 23:50:33 +02:00
Mobile: Fixes #3815: Fixed btoa error
This commit is contained in:
13
ReactNativeClient/package-lock.json
generated
13
ReactNativeClient/package-lock.json
generated
@ -4881,7 +4881,6 @@
|
|||||||
"minimatch": {
|
"minimatch": {
|
||||||
"version": "3.0.4",
|
"version": "3.0.4",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"brace-expansion": "^1.1.7"
|
"brace-expansion": "^1.1.7"
|
||||||
}
|
}
|
||||||
@ -8078,9 +8077,9 @@
|
|||||||
"integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ="
|
"integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ="
|
||||||
},
|
},
|
||||||
"patch-package": {
|
"patch-package": {
|
||||||
"version": "6.2.1",
|
"version": "6.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/patch-package/-/patch-package-6.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/patch-package/-/patch-package-6.2.2.tgz",
|
||||||
"integrity": "sha512-dfCtQor63PPij6DDYtCzBRoO5nNAcMSg7Cmh+DLhR+s3t0OLQBdvFxJksZHBe1J2MjsSWDjTF4+oQKFbdkssIg==",
|
"integrity": "sha512-YqScVYkVcClUY0v8fF0kWOjDYopzIM8e3bj/RU1DPeEF14+dCGm6UeOYm4jvCyxqIEQ5/eJzmbWfDWnUleFNMg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@yarnpkg/lockfile": "^1.1.0",
|
"@yarnpkg/lockfile": "^1.1.0",
|
||||||
@ -9993,9 +9992,9 @@
|
|||||||
"integrity": "sha1-VusCfWW00tzmyy4tMsTUr8nh1wc="
|
"integrity": "sha1-VusCfWW00tzmyy4tMsTUr8nh1wc="
|
||||||
},
|
},
|
||||||
"slug": {
|
"slug": {
|
||||||
"version": "3.3.4",
|
"version": "3.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/slug/-/slug-3.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/slug/-/slug-3.4.0.tgz",
|
||||||
"integrity": "sha512-VpHbtRCEWmgaZsrZcTsVl/Dhw98lcrOYDO17DNmJCNpppI6s3qJvnNu2Q3D4L84/2bi6vkW40mjNQI9oGQsflg=="
|
"integrity": "sha512-s234DYtuRCkzVNL8dL9BRFNmlZUF9NUGjxWG+wwBKPzUFUADrhkjKGVNhDaZs2Lc+UKh3085KItaKilwJA9I2Q=="
|
||||||
},
|
},
|
||||||
"slugify": {
|
"slugify": {
|
||||||
"version": "1.3.6",
|
"version": "1.3.6",
|
||||||
|
@ -83,13 +83,13 @@
|
|||||||
"redux": "4.0.0",
|
"redux": "4.0.0",
|
||||||
"reselect": "^4.0.0",
|
"reselect": "^4.0.0",
|
||||||
"rn-fetch-blob": "^0.12.0",
|
"rn-fetch-blob": "^0.12.0",
|
||||||
|
"slug": "^3.4.0",
|
||||||
"stream": "0.0.2",
|
"stream": "0.0.2",
|
||||||
"string-natural-compare": "^2.0.2",
|
"string-natural-compare": "^2.0.2",
|
||||||
"string-padding": "^1.0.2",
|
"string-padding": "^1.0.2",
|
||||||
"timers": "^0.1.1",
|
"timers": "^0.1.1",
|
||||||
"url": "^0.11.0",
|
"url": "^0.11.0",
|
||||||
"url-parse": "^1.4.7",
|
"url-parse": "^1.4.7",
|
||||||
"slug": "^3.3.4",
|
|
||||||
"uuid": "^3.0.1",
|
"uuid": "^3.0.1",
|
||||||
"valid-url": "^1.0.9",
|
"valid-url": "^1.0.9",
|
||||||
"word-wrap": "^1.2.3",
|
"word-wrap": "^1.2.3",
|
||||||
@ -104,7 +104,7 @@
|
|||||||
"gulp": "^4.0.2",
|
"gulp": "^4.0.2",
|
||||||
"jetifier": "^1.6.5",
|
"jetifier": "^1.6.5",
|
||||||
"metro-react-native-babel-preset": "^0.54.1",
|
"metro-react-native-babel-preset": "^0.54.1",
|
||||||
"patch-package": "^6.2.1",
|
"patch-package": "^6.2.2",
|
||||||
"react-test-renderer": "^16.8.3"
|
"react-test-renderer": "^16.8.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
38
patches/slug+3.4.0.patch
Normal file
38
patches/slug+3.4.0.patch
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
diff --git a/node_modules/slug/slug.js b/node_modules/slug/slug.js
|
||||||
|
index b40320b..2be9650 100644
|
||||||
|
--- a/node_modules/slug/slug.js
|
||||||
|
+++ b/node_modules/slug/slug.js
|
||||||
|
@@ -51,13 +51,31 @@
|
||||||
|
throw new Error('String "' + str + '" reaches code believed to be unreachable; please open an issue at https://github.com/Trott/slug/issues/new')
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (typeof window === 'undefined') {
|
||||||
|
+ if (typeof window !== 'undefined' && window.btoa) {
|
||||||
|
+ base64 = function (input) {
|
||||||
|
+ return btoa(unescape(encodeURIComponent(input)))
|
||||||
|
+ }
|
||||||
|
+ } else if (typeof Buffer !== 'undefined') {
|
||||||
|
base64 = function (input) {
|
||||||
|
return Buffer.from(input).toString('base64')
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ // Polyfill for environments that don't have any btoa or Buffer class (eg. React Native)
|
||||||
|
+ // Copied from https://github.com/davidchambers/Base64.js/blob/a121f75bb10c8dd5d557886c4b1069b31258d230/base64.js#L22
|
||||||
|
base64 = function (input) {
|
||||||
|
- return btoa(unescape(encodeURIComponent(input)))
|
||||||
|
+ var str = unescape(encodeURIComponent(input + ''))
|
||||||
|
+ for (
|
||||||
|
+ var block, charCode, idx = 0, map = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=', output = '';
|
||||||
|
+ str.charAt(idx | 0) || (map = '=', idx % 1);
|
||||||
|
+ output += map.charAt(63 & block >> 8 - idx % 1 * 8)
|
||||||
|
+ ) {
|
||||||
|
+ charCode = str.charCodeAt(idx += 3 / 4)
|
||||||
|
+ if (charCode > 0xFF) {
|
||||||
|
+ throw new Error("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.")
|
||||||
|
+ }
|
||||||
|
+ block = block << 8 | charCode
|
||||||
|
+ }
|
||||||
|
+ return output
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Reference in New Issue
Block a user