Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ impl<Fs: FileSystem> ResolverGeneric<Fs> {
}
// 2. If X begins with '/'
// a. set Y to be the file system root
let path = self.cache.value(Path::new(specifier));
let path = self.cache.value(Path::new(specifier.trim_end_matches('/')));
if let Some(path) = self.load_as_file_or_directory(&path, specifier, tsconfig, ctx)? {
return Ok(path);
}
Expand Down
5 changes: 5 additions & 0 deletions src/tests/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ fn resolve() {
let resolver = Resolver::default();

let main1_js_path = f.join("main1.js").to_string_lossy().to_string();
let m2 = f.join("node_modules").join("m2");
let m2_specifier = m2.to_string_lossy().to_string();
let m2_trailing_slash = m2_specifier.clone() + "/";

#[rustfmt::skip]
let pass = [
("absolute path", f.clone(), main1_js_path.as_str(), f.join("main1.js")),
("absolute path to package", f.clone(), m2_specifier.as_str(), m2.join("b.js")),
("absolute path to package with trailing slash", f.clone(), m2_trailing_slash.as_str(), m2.join("b.js")),
("file with .js", f.clone(), "./main1.js", f.join("main1.js")),
("file without extension", f.clone(), "./main1", f.join("main1.js")),
("another file with .js", f.clone(), "./a.js", f.join("a.js")),
Expand Down
Loading