You've already forked joplin
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:
@@ -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, '');
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user