From c59152e4000393ad122855c26198c1d942497c00 Mon Sep 17 00:00:00 2001 From: Simon Lecoq <22963968+lowlighter@users.noreply.github.com> Date: Fri, 25 Feb 2022 01:26:13 +0100 Subject: feat(cli): support data url (#13667) Closes #11141 --- cli/tests/testdata/compiler_api_test.ts | 16 ++++++++++++++++ runtime/js/40_compiler_api.js | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/cli/tests/testdata/compiler_api_test.ts b/cli/tests/testdata/compiler_api_test.ts index 168d70ce6..81f049ac1 100644 --- a/cli/tests/testdata/compiler_api_test.ts +++ b/cli/tests/testdata/compiler_api_test.ts @@ -45,6 +45,22 @@ Deno.test({ }, }); +Deno.test({ + name: "Deno.emit() - data url", + async fn() { + const data = + "data:application/javascript;base64,Y29uc29sZS5sb2coImhlbGxvIHdvcmxkIik7"; + const { diagnostics, files, ignoredOptions, stats } = await Deno.emit(data); + assertEquals(diagnostics.length, 0); + assert(!ignoredOptions); + assertEquals(stats.length, 0); + const keys = Object.keys(files); + assertEquals(keys.length, 1); + assertEquals(keys[0], data); + assertStringIncludes(files[keys[0]], 'console.log("hello world");'); + }, +}); + Deno.test({ name: "Deno.emit() - compiler options effects emit", async fn() { diff --git a/runtime/js/40_compiler_api.js b/runtime/js/40_compiler_api.js index 011373eb0..bd787ef74 100644 --- a/runtime/js/40_compiler_api.js +++ b/runtime/js/40_compiler_api.js @@ -54,7 +54,7 @@ function checkRelative(specifier) { return StringPrototypeMatch( specifier, - /^([\.\/\\]|https?:\/{2}|file:\/{2})/, + /^([\.\/\\]|https?:\/{2}|file:\/{2}|data:)/, ) ? specifier : `./${specifier}`; -- cgit v1.2.3