From 64abe902e5912b29f02fe3f886e425bb56612f01 Mon Sep 17 00:00:00 2001 From: Leo Kettmeir Date: Thu, 20 Feb 2025 04:29:11 +0100 Subject: [PATCH] fix: don't panic when running with // as a filepath (#28189) Fixes #28128 --- cli/args/flags.rs | 2 +- tests/specs/run/with_double_slash/__test__.jsonc | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 tests/specs/run/with_double_slash/__test__.jsonc diff --git a/cli/args/flags.rs b/cli/args/flags.rs index 8e06d70274..02d30d055c 100644 --- a/cli/args/flags.rs +++ b/cli/args/flags.rs @@ -1006,7 +1006,7 @@ impl Flags { || module_specifier.scheme() == "npm" { if let Ok(p) = url_to_file_path(&module_specifier) { - Some(vec![p.parent().unwrap().to_path_buf()]) + p.parent().map(|parent| vec![parent.to_path_buf()]) } else { Some(vec![current_dir.to_path_buf()]) } diff --git a/tests/specs/run/with_double_slash/__test__.jsonc b/tests/specs/run/with_double_slash/__test__.jsonc new file mode 100644 index 0000000000..365db357cd --- /dev/null +++ b/tests/specs/run/with_double_slash/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run //", + "exitCode": 1, + "output": "error: [WILDCARD]" +}