Skip to content

Commit 2bca624

Browse files
committed
Fix judgement of an edge condition
Signed-off-by: Hollow Man <[email protected]>
1 parent 7df1596 commit 2bca624

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/utils/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,16 @@ fn adjust_links<'a>(
219219
.to_str()
220220
.expect("utf-8 paths only")
221221
.to_owned();
222-
write!(unnormalized_path, "{}/{}", normalize_path(base), redirect)
223-
.unwrap();
222+
223+
let normalized_base =
224+
normalize_path(base).trim_matches('/').to_owned();
225+
if !normalized_base.is_empty() {
226+
write!(unnormalized_path, "{}/{}", normalized_base, redirect)
227+
.unwrap();
228+
} else {
229+
unnormalized_path =
230+
redirect.to_string().trim_start_matches('/').to_string();
231+
}
224232
}
225233

226234
// original without anchors, need to append link anchors

0 commit comments

Comments
 (0)