brianloveswords / base64url

For encoding and decoding base64url!
MIT License
225 stars 44 forks source link

Compatibility issue on IE 11 due to default parameters #35

Closed QingpingMeng closed 6 years ago

QingpingMeng commented 6 years ago

Since this package is targeting to es6, default parameters will be omitted by ts compiler. However IE 11 doesn't support default parameters.

function decode(base64url: string, encoding: string = "utf8"): string {
    return Buffer.from(toBase64(base64url), "base64").toString(encoding);
}

function encode(input: string | Buffer, encoding: string = "utf8"): string {
    if (Buffer.isBuffer(input)) {
        return fromBase64(input.toString("base64"));
    }
    return fromBase64(Buffer.from(input as string, encoding).toString("base64"));
};

Suggested solution: change tsconfig.json to target to 'es5' or avoid using default parameters

tassoevan commented 6 years ago

blockstack is affect by this issue: https://github.com/blockstack/blockstack.js/issues/541