diff --git a/pkg/dart2wasm/bin/run_wasm.js b/pkg/dart2wasm/bin/run_wasm.js index c24cd1324b6..59049559d01 100644 --- a/pkg/dart2wasm/bin/run_wasm.js +++ b/pkg/dart2wasm/bin/run_wasm.js @@ -364,7 +364,11 @@ if (argsSplit != -1) { self.Response = function () { } self.location = {} - self.location.href = 'file://' + args[wasmArg]; + if (args[wasmArg].startsWith('/')) { + self.location.href = 'file://' + args[wasmArg]; + } else { + self.location.href = args[wasmArg]; + } // Signals `Stopwatch._initTicker` to use `Date.now` to get ticks instead of // `performance.now`, as it's not available in d8. diff --git a/tests/web/wasm/uri_base_test.dart b/tests/web/wasm/uri_base_test.dart new file mode 100644 index 00000000000..74c4252e20a --- /dev/null +++ b/tests/web/wasm/uri_base_test.dart @@ -0,0 +1,7 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +void main() { + print(Uri.base.toFilePath()); // should not crash +} diff --git a/tests/web/web.status b/tests/web/web.status index 5a7a9407c0e..216bd2785f9 100644 --- a/tests/web/web.status +++ b/tests/web/web.status @@ -57,6 +57,7 @@ code_motion_exception_test: Skip # Required V8 specific format of JavaScript err [ $compiler == dart2wasm && $runtime != d8 ] wasm/source_map_simple_test: SkipByDesign # Reads source map file using d8's readbuffer wasm/source_map_simple_optimized_test: SkipByDesign # Reads source map file using d8's readbuffer +wasm/uri_base_test: SkipByDesign # Converts Uri.base to file path [ $compiler == dartk && $runtime == vm ] new_from_env_test: SkipByDesign # dart2js only test