From f9beb928186f4edb07e07c96b677f14e75c428bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 24 Aug 2023 11:21:34 +0200 Subject: refactor: use "deno_config" crate (#20260) Moved the configuration file to https://github.com/denoland/deno_config as we will have to use it in other projects. --- cli/util/path.rs | 35 ----------------------------------- 1 file changed, 35 deletions(-) (limited to 'cli/util/path.rs') diff --git a/cli/util/path.rs b/cli/util/path.rs index ba1d0d926..b1e92015c 100644 --- a/cli/util/path.rs +++ b/cli/util/path.rs @@ -110,25 +110,6 @@ pub fn specifier_to_file_path( } } -/// Gets the parent of this module specifier. -pub fn specifier_parent(specifier: &ModuleSpecifier) -> ModuleSpecifier { - let mut specifier = specifier.clone(); - // don't use specifier.segments() because it will strip the leading slash - let mut segments = specifier.path().split('/').collect::>(); - if segments.iter().all(|s| s.is_empty()) { - return specifier; - } - if let Some(last) = segments.last() { - if last.is_empty() { - segments.pop(); - } - segments.pop(); - let new_path = format!("{}/", segments.join("/")); - specifier.set_path(&new_path); - } - specifier -} - /// `from.make_relative(to)` but with fixes. pub fn relative_specifier( from: &ModuleSpecifier, @@ -293,22 +274,6 @@ mod test { } } - #[test] - fn test_specifier_parent() { - run_test("file:///", "file:///"); - run_test("file:///test", "file:///"); - run_test("file:///test/", "file:///"); - run_test("file:///test/other", "file:///test/"); - run_test("file:///test/other.txt", "file:///test/"); - run_test("file:///test/other/", "file:///test/"); - - fn run_test(specifier: &str, expected: &str) { - let result = - specifier_parent(&ModuleSpecifier::parse(specifier).unwrap()); - assert_eq!(result.to_string(), expected); - } - } - #[test] fn test_relative_specifier() { let fixtures: Vec<(&str, &str, Option<&str>)> = vec![ -- cgit v1.2.3