Skip to content

A Promise that resolves to a string should be treated as non-binary #707

@hubgit

Description

@hubgit

I expected both of these types of input (a string, and a Promise that resolves to a string) to produce the same output:

var zip = new JSZip();
zip.file("file.txt", "Hèllo");
const output = await zip.file("file.txt").async("text");
// Hèllo
var zip = new JSZip();
zip.file("file.txt", Promise.resolve("Hèllo"));
const output = await zip.file("file.txt").async("text");
// H�llo

but the second version (where the input string is wrapped in a Promise) produces output text with incorrect encoding unless you explicitly set { binary: false }:

var zip = new JSZip();
zip.file("file.txt", Promise.resolve("Hèllo"), { binary: false });
const output = await zip.file("file.txt").async("text");
// Hèllo

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions