Skip to content

Commit

Permalink
fix(resolver): handle trailing slashes in the path with more sense (#414
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ramfox authored Oct 25, 2022
1 parent f861102 commit 9ef95e8
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions iroh-resolver/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1102,13 +1102,7 @@ impl<T: ContentLoader> Resolver<T> {
let mut current = node;
let mut resolved_path = vec![cid];

for part in tail {
// TODO(ramfox): we currently add an empty string to the path.tail vec
// when the original path ends in a "/". This is causing errors because
// we attempt to index into the data using an empty string, which fails
if part.is_empty() {
continue;
}
for part in tail.iter().filter(|s| !s.is_empty()) {
self.inner_resolve(&mut current, &mut resolved_path, part, &mut ctx)
.await?;
}
Expand Down Expand Up @@ -1205,13 +1199,7 @@ impl<T: ContentLoader> Resolver<T> {
let mut current = root;
let mut codec = codec;

for part in path {
// TODO(ramfox): we currently add an empty string to the path.tail vec
// when the original path ends in a "/". This is causing errors because
// we attempt to index into the data using an empty string, which fails
if part.is_empty() {
continue;
}
for part in path.iter().filter(|s| !s.is_empty()) {
if let libipld::Ipld::Link(c) = current {
(codec, current) = self.load_ipld_link(c, ctx).await?;
}
Expand Down

0 comments on commit 9ef95e8

Please sign in to comment.