Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
f
  • Loading branch information
XadillaX committed Apr 27, 2021
commit beceed4c63bc5c221a2d220baef5c508142ffbc9
14 changes: 6 additions & 8 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1215,12 +1215,6 @@ if (internalBinding('config').hasIntl) {

let DOMException;

const lazyInvalidCharError = hideStackFrames((message, name) => {
if (DOMException === undefined)
DOMException = internalBinding('messaging').DOMException;
throw new DOMException('Invalid character', 'InvalidCharacterError');
});

function btoa(input) {
input = `${input}`;
let ret;
Expand All @@ -1229,7 +1223,9 @@ function btoa(input) {
} catch (e) {
if (DOMException === undefined)
DOMException = internalBinding('messaging').DOMException;
throw new DOMException('Invalid character', 'InvalidCharacterError');
let code = 'Error';
if (e.code === 'ERR_INVALID_CHARACTER') code = 'InvalidCharacterError';
throw new DOMException(e.message, code);
}
return ret;
}
Expand All @@ -1242,7 +1238,9 @@ function atob(input) {
} catch (e) {
if (DOMException === undefined)
DOMException = internalBinding('messaging').DOMException;
throw new DOMException('Invalid character', 'InvalidCharacterError');
let code = 'Error';
if (e.code === 'ERR_INVALID_CHARACTER') code = 'InvalidCharacterError';
throw new DOMException(e.message, code);
}
return ret;
}
Expand Down