summaryrefslogtreecommitdiff
path: root/ext/node/path.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-07-25 19:08:14 -0400
committerGitHub <noreply@github.com>2024-07-25 19:08:14 -0400
commit3bf147fe287ac779b20d318daba56b336f356adf (patch)
tree3b5bfe2a1ad918b275a2cd08f7dcc05f90a180ab /ext/node/path.rs
parent0cf7f268a7df7711ac6ab8c2c67b4d7abf454fcd (diff)
refactor: decouple node resolution from deno_core (#24724)
Diffstat (limited to 'ext/node/path.rs')
-rw-r--r--ext/node/path.rs50
1 files changed, 0 insertions, 50 deletions
diff --git a/ext/node/path.rs b/ext/node/path.rs
deleted file mode 100644
index 0f151edaf..000000000
--- a/ext/node/path.rs
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
-
-use std::path::Component;
-use std::path::Path;
-use std::path::PathBuf;
-
-use deno_core::ModuleSpecifier;
-
-/// Extension to path_clean::PathClean
-pub trait PathClean<T> {
- fn clean(&self) -> T;
-}
-
-impl PathClean<PathBuf> for PathBuf {
- fn clean(&self) -> PathBuf {
- let path = path_clean::PathClean::clean(self);
- if cfg!(windows) && path.to_string_lossy().contains("..\\") {
- // temporary workaround because path_clean::PathClean::clean is
- // not good enough on windows
- let mut components = Vec::new();
-
- for component in path.components() {
- match component {
- Component::CurDir => {
- // skip
- }
- Component::ParentDir => {
- let maybe_last_component = components.pop();
- if !matches!(maybe_last_component, Some(Component::Normal(_))) {
- panic!("Error normalizing: {}", path.display());
- }
- }
- Component::Normal(_) | Component::RootDir | Component::Prefix(_) => {
- components.push(component);
- }
- }
- }
- components.into_iter().collect::<PathBuf>()
- } else {
- path
- }
- }
-}
-
-pub(crate) fn to_file_specifier(path: &Path) -> ModuleSpecifier {
- match ModuleSpecifier::from_file_path(path) {
- Ok(url) => url,
- Err(_) => panic!("Invalid path: {}", path.display()),
- }
-}