From 0eb714ae16be3f008fee97a2378429d796be4157 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Skwara?= Date: Sat, 15 Jul 2023 22:33:20 +0200 Subject: [PATCH] [MM-46] Fix polish characters encoding --- package-lock.json | 11 ----------- package.json | 1 - src/utils/parseToUTF8.ts | 5 +++++ src/utils/prepareName.ts | 4 ++-- 4 files changed, 7 insertions(+), 14 deletions(-) create mode 100644 src/utils/parseToUTF8.ts diff --git a/package-lock.json b/package-lock.json index 3e76c78..4d7b240 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,7 +30,6 @@ "multer-s3": "^3.0.1", "pkg": "^5.8.0", "pkg-api": "^1.0.0", - "remove-accents": "^0.4.2", "validator": "^13.7.0", "xss-clean": "^0.1.1" }, @@ -5965,11 +5964,6 @@ "url": "https://github.com/sponsors/mysticatea" } }, - "node_modules/remove-accents": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/remove-accents/-/remove-accents-0.4.2.tgz", - "integrity": "sha512-7pXIJqJOq5tFgG1A2Zxti3Ht8jJF337m4sowbuHsW30ZnkQFnDzy9qBNhgzX8ZLW4+UBcXiiR7SwR6pokHsxiA==" - }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -11939,11 +11933,6 @@ "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", "dev": true }, - "remove-accents": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/remove-accents/-/remove-accents-0.4.2.tgz", - "integrity": "sha512-7pXIJqJOq5tFgG1A2Zxti3Ht8jJF337m4sowbuHsW30ZnkQFnDzy9qBNhgzX8ZLW4+UBcXiiR7SwR6pokHsxiA==" - }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", diff --git a/package.json b/package.json index f4fb7d4..c2d9fdd 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,6 @@ "multer-s3": "^3.0.1", "pkg": "^5.8.0", "pkg-api": "^1.0.0", - "remove-accents": "^0.4.2", "validator": "^13.7.0", "xss-clean": "^0.1.1" }, diff --git a/src/utils/parseToUTF8.ts b/src/utils/parseToUTF8.ts new file mode 100644 index 0000000..d63a159 --- /dev/null +++ b/src/utils/parseToUTF8.ts @@ -0,0 +1,5 @@ +// Taken from https://github.com/expressjs/multer/issues/1104#issuecomment-1152987772 +// TODO Maybe this PR will fix the multer issue: https://github.com/expressjs/multer/pull/1210 + +export default (name: string): string => + Buffer.from(name, 'latin1').toString('utf8'); diff --git a/src/utils/prepareName.ts b/src/utils/prepareName.ts index 60f0e54..bc8f7df 100644 --- a/src/utils/prepareName.ts +++ b/src/utils/prepareName.ts @@ -1,3 +1,3 @@ -import removeAccents from 'remove-accents'; +import parseToUTF8 from './parseToUTF8'; -export default (name: string) => removeAccents(name); +export default (name: string): string => parseToUTF8(name);