Skip to content

Commit

Permalink
Ignore duplicate slashes at the start of relative path specifiers (#9048
Browse files Browse the repository at this point in the history
)
  • Loading branch information
devongovett committed May 27, 2023
1 parent 08c3a04 commit 8e1dd64
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 8 additions & 0 deletions packages/utils/node-resolver-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,14 @@ mod tests {
.0,
Resolution::Path(root().join("bar.js"))
);
assert_eq!(
test_resolver()
.resolve(".///bar.js", &root().join("foo.js"), SpecifierType::Esm)
.result
.unwrap()
.0,
Resolution::Path(root().join("bar.js"))
);
assert_eq!(
test_resolver()
.resolve("./bar", &root().join("foo.js"), SpecifierType::Esm)
Expand Down
6 changes: 5 additions & 1 deletion packages/utils/node-resolver-rs/src/specifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ impl<'a> Specifier<'a> {

Ok(match specifier.as_bytes()[0] {
b'.' => {
let specifier = specifier.strip_prefix("./").unwrap_or(specifier);
let specifier = if let Some(specifier) = specifier.strip_prefix("./") {
specifier.trim_start_matches('/')
} else {
specifier
};
let (path, query) = decode_path(specifier, specifier_type);
(Specifier::Relative(path), query)
}
Expand Down

0 comments on commit 8e1dd64

Please sign in to comment.