Skip to content

Commit 5875b13

Browse files
committed
fix UTF-8 characters in base64 source map
1 parent 7defb4a commit 5875b13

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

code.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
////////////////////////////////////////////////////////////////////////////////
5555
// Loading
5656

57+
const utf8ToUTF16 = x => decodeURIComponent(escape(x));
58+
const utf16ToUTF8 = x => unescape(encodeURIComponent(x));
59+
5760
const promptText = document.getElementById('promptText');
5861
const errorText = document.getElementById('errorText');
5962
const toolbar = document.getElementById('toolbar');
@@ -102,7 +105,7 @@
102105
// Check for a non-empty data URL payload
103106
if (match && match[2]) {
104107
const parts = match[1].split(';');
105-
const map = parts.indexOf('base64') >= 0 ? atob(match[2]) : decodeURIComponent(match[2]);
108+
const map = parts.indexOf('base64') >= 0 ? utf8ToUTF16(atob(match[2])) : decodeURIComponent(match[2]);
106109
finishLoading(code, map);
107110
}
108111

@@ -1543,9 +1546,6 @@
15431546
////////////////////////////////////////////////////////////////////////////////
15441547
// Shareable URLs
15451548

1546-
const utf8ToUTF16 = x => decodeURIComponent(escape(x));
1547-
const utf16ToUTF8 = x => unescape(encodeURIComponent(x));
1548-
15491549
function loadFromHash() {
15501550
try {
15511551
// Reads a string in length-prefix form separated by a null character. This

0 commit comments

Comments
 (0)