summaryrefslogtreecommitdiff
path: root/cli/util/path.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/util/path.rs')
-rw-r--r--cli/util/path.rs35
1 files changed, 0 insertions, 35 deletions
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::<Vec<_>>();
- 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,
@@ -294,22 +275,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![
("file:///from", "file:///to", Some("./to")),