diff --git a/src/Parser.js b/src/Parser.js index f096fa5..2ad6d66 100644 --- a/src/Parser.js +++ b/src/Parser.js @@ -257,15 +257,7 @@ function nodeIsImport(elt) { function generateScriptDataUrl(script) { var scriptContent = generateScriptContent(script); - var b64 = 'data:text/javascript'; - // base64 may be smaller, but does not handle unicode characters - // attempt base64 first, fall back to escaped text - try { - b64 += (';base64,' + btoa(scriptContent)); - } catch(e) { - b64 += (';charset=utf-8,' + encodeURIComponent(scriptContent)); - } - return b64; + return 'data:text/javascript;charset=utf-8,' + encodeURIComponent(scriptContent); } function generateScriptContent(script) { diff --git a/test/html/encoding.html b/test/html/encoding.html new file mode 100644 index 0000000..e51ea46 --- /dev/null +++ b/test/html/encoding.html @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + diff --git a/test/html/imports/encoding-import.html b/test/html/imports/encoding-import.html new file mode 100644 index 0000000..d31686f --- /dev/null +++ b/test/html/imports/encoding-import.html @@ -0,0 +1,6 @@ + diff --git a/test/js/tests.js b/test/js/tests.js index 80346fe..507c67f 100644 --- a/test/js/tests.js +++ b/test/js/tests.js @@ -18,4 +18,5 @@ htmlSuite('HTMLImports', function() { // TODO(sjmiles): feature not implemented currently //htmlTest('html/dynamic-elements.html'); htmlTest('html/csp.html'); + htmlTest('html/encoding.html'); });