diff options
Diffstat (limited to 'core')
| -rw-r--r-- | core/lib.rs | 1 | ||||
| -rw-r--r-- | core/module_specifier.rs | 26 | ||||
| -rw-r--r-- | core/ops_builtin_v8.rs | 15 |
3 files changed, 5 insertions, 37 deletions
diff --git a/core/lib.rs b/core/lib.rs index 08df6e44d..7751be6e8 100644 --- a/core/lib.rs +++ b/core/lib.rs @@ -74,7 +74,6 @@ pub use crate::module_specifier::resolve_url; pub use crate::module_specifier::resolve_url_or_path; pub use crate::module_specifier::ModuleResolutionError; pub use crate::module_specifier::ModuleSpecifier; -pub use crate::module_specifier::DUMMY_SPECIFIER; pub use crate::modules::ExtModuleLoader; pub use crate::modules::ExtModuleLoaderCb; pub use crate::modules::FsModuleLoader; diff --git a/core/module_specifier.rs b/core/module_specifier.rs index 94ccd298c..20358e79c 100644 --- a/core/module_specifier.rs +++ b/core/module_specifier.rs @@ -1,7 +1,6 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. use crate::normalize_path; -use std::env::current_dir; use std::error::Error; use std::fmt; use std::path::Path; @@ -9,8 +8,6 @@ use std::path::PathBuf; use url::ParseError; use url::Url; -pub const DUMMY_SPECIFIER: &str = "<unknown>"; - /// Error indicating the reason resolving a module specifier failed. #[derive(Clone, Debug, Eq, PartialEq)] pub enum ModuleResolutionError { @@ -85,18 +82,7 @@ pub fn resolve_import( // 3. Return the result of applying the URL parser to specifier with base // URL as the base URL. Err(ParseError::RelativeUrlWithoutBase) => { - let base = if base == DUMMY_SPECIFIER { - // Handle <unknown> case, happening under e.g. repl. - // Use CWD for such case. - - // Forcefully join base to current dir. - // Otherwise, later joining in Url would be interpreted in - // the parent directory (appending trailing slash does not work) - let path = current_dir().unwrap().join(base); - Url::from_file_path(path).unwrap() - } else { - Url::parse(base).map_err(InvalidBaseUrl)? - }; + let base = Url::parse(base).map_err(InvalidBaseUrl)?; base.join(specifier).map_err(InvalidUrl)? } @@ -181,20 +167,12 @@ mod tests { use super::*; use crate::serde_json::from_value; use crate::serde_json::json; + use std::env::current_dir; use std::path::Path; #[test] fn test_resolve_import() { - fn get_path(specifier: &str) -> Url { - let base_path = current_dir().unwrap().join("<unknown>"); - let base_url = Url::from_file_path(base_path).unwrap(); - base_url.join(specifier).unwrap() - } - let awesome = get_path("/awesome.ts"); - let awesome_srv = get_path("/service/awesome.ts"); let tests = vec