Skip to content

Commit

Permalink
remove spaces from data url mime type
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Jul 20, 2020
1 parent ce6b127 commit d2517b6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/bundler/bundler.go
Expand Up @@ -196,7 +196,7 @@ func parseFile(args parseArgs) {
mimeType = http.DetectContentType([]byte(source.Contents))
}
encoded := base64.StdEncoding.EncodeToString([]byte(source.Contents))
url := "data:" + mimeType + ";base64," + encoded
url := "data:" + strings.ReplaceAll(mimeType, "; ", ";") + ";base64," + encoded
expr := ast.Expr{Data: &ast.EString{Value: lexer.StringToUTF16(url)}}
result.file.ast = parser.LazyExportAST(args.log, source, args.options, expr, "")
result.file.ignoreIfUnused = true
Expand Down
4 changes: 2 additions & 2 deletions internal/bundler/bundler_loader_test.go
Expand Up @@ -401,11 +401,11 @@ func TestLoaderDataURLCommonJSAndES6(t *testing.T) {
expected: map[string]string{
"/out.js": `// /x.txt
var require_x = __commonJS((exports, module) => {
module.exports = "data:text/plain; charset=utf-8;base64,eA==";
module.exports = "data:text/plain;charset=utf-8;base64,eA==";
});
// /y.txt
var y_default = "data:text/plain; charset=utf-8;base64,eQ==";
var y_default = "data:text/plain;charset=utf-8;base64,eQ==";
// /entry.js
const x_url = require_x();
Expand Down

0 comments on commit d2517b6

Please sign in to comment.