Skip to content

Commit cfd4006

Browse files
committed
refactor: fix warnings in import.rs
1 parent 78570de commit cfd4006

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/command/import.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ fn write_post(
319319
file.write_all(meta.render()?.as_bytes())?;
320320
file.write_all(b"\n\n")?;
321321
let basename = path.basename().ok_or_eyre("path has no basename")?;
322-
let unsafe_html = process_content(&e_content, basename, &base_href, &RealAttachmentsContext)?;
322+
let unsafe_html = process_content(e_content, basename, base_href, &RealAttachmentsContext)?;
323323
let post = TemplatedPost::filter(&unsafe_html, Some(path.clone()))?;
324324
file.write_all(post.safe_html.as_bytes())?;
325325
info!("click here to reply: {}", path.compose_reply_url());
@@ -378,8 +378,8 @@ fn process_content(
378378
if attr_names.contains(&attr.name) {
379379
// rewrite urls in links to bake in the `base_href`.
380380
let old_url = attr.value.to_str().to_owned();
381-
let new_url = if old_url.starts_with('#') {
382-
format!("#user-content-{}", &old_url[1..])
381+
let new_url = if let Some(end) = old_url.strip_prefix('#') {
382+
format!("#user-content-{end}")
383383
} else {
384384
base_href.join(&old_url)?.to_string()
385385
};

0 commit comments

Comments
 (0)