fix: change method for alloc string to buffer (#777)
String.length is not appropriate for calculating buffer size when non-alphabet letter is included in content. Change the method Buffer.alloc to Buffer.from as directed by the nodejs document.
Esse commit está contido em:
@@ -23,6 +23,7 @@ describe("LocalFileSystem Storage Provider", () => {
|
||||
a: 1,
|
||||
b: 2,
|
||||
c: 3,
|
||||
d: "한글 中國 にほんご",
|
||||
};
|
||||
|
||||
await localFileSystem.writeText(filePath, JSON.stringify(contents, null, 4));
|
||||
|
||||
@@ -71,7 +71,7 @@ export default class LocalFileSystem implements IStorageProvider {
|
||||
}
|
||||
|
||||
public writeText(filePath: string, contents: string): Promise<void> {
|
||||
const buffer = Buffer.alloc(contents.length, contents);
|
||||
const buffer = Buffer.from(contents);
|
||||
return this.writeBinary(filePath, buffer);
|
||||
}
|
||||
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário