1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-23 22:36:32 +02:00

Desktop: Fixes #9868: Fix markdown (frontmatter) notes that start with a UTF-8 BOM aren't imporetd correctly (#9875)

This commit is contained in:
Henry Heino
2024-02-08 08:55:34 -08:00
committed by GitHub
parent 628877147e
commit d614d40cfd
4 changed files with 28 additions and 1 deletions

View File

@@ -303,3 +303,11 @@ export function scriptType(s: string) {
return 'en';
}
// A UTF-8/UTF-16 byte order mark can appear at the start of a file and
// can break logic that relies on a file starting with specific text.
// See https://github.com/laurent22/joplin/issues/9868
export const stripBom = (text: string) => {
// Remove the UTF-16 BOM --- NodeJS seems to convert UTF-8 BOMs to UTF-16 BOMs
// when reading files.
return text.replace(/^\ufeff/u, '');
};