Skip to content

Commit 808d720

Browse files
committed
chore: update snapshots
1 parent d3935e2 commit 808d720

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/runtime/sourceMaps.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
// Polyfill for btoa in Node.js
22
/* global btoa */
3-
function getBtoa() {
4-
if (typeof btoa === "function") return btoa;
5-
return (str) => Buffer.from(str, "binary").toString("base64");
6-
}
73

84
module.exports = (item) => {
95
const [, content, , cssMapping] = item;
@@ -12,8 +8,15 @@ module.exports = (item) => {
128
return content;
139
}
1410

15-
const btoaFn = getBtoa();
16-
const base64 = btoaFn(
11+
const btoaPolyfill =
12+
typeof btoa === "undefined"
13+
? (str) => {
14+
const buffer =
15+
str instanceof Buffer ? str : Buffer.from(str.toString(), "binary");
16+
return buffer.toString("base64");
17+
}
18+
: btoa;
19+
const base64 = btoaPolyfill(
1720
unescape(encodeURIComponent(JSON.stringify(cssMapping))),
1821
);
1922
const data = `sourceMappingURL=data:application/json;charset=utf-8;base64,${base64}`;

0 commit comments

Comments
 (0)