diff options
Diffstat (limited to 'ext/node/path.rs')
-rw-r--r-- | ext/node/path.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/ext/node/path.rs b/ext/node/path.rs index 71cc0741e..e20555a2c 100644 --- a/ext/node/path.rs +++ b/ext/node/path.rs @@ -1,8 +1,11 @@ // Copyright 2018-2023 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; @@ -38,3 +41,10 @@ impl PathClean<PathBuf> for PathBuf { } } } + +pub(crate) fn to_file_specifier(path: &Path) -> ModuleSpecifier { + match ModuleSpecifier::from_file_path(path) { + Ok(url) => url, + Err(_) => panic!("Invalid path: {}", path.display()), + } +} |