fix: don't emit hash fragment for internal links if hash is empty (#3660)

* fix: don't emit hash fragment for internal links if hash is empty

* add test
This commit is contained in:
Jonathan Kelley authored and GitHub committed 2025-01-28 10:09:27 -08:00
1 parent 861e6c1984
commit 155a2467be
2 files changed
+34 -1

No files matched your search

+6 -1
View File
@@ -25,7 +25,12 @@ impl HashFragment {
pub fn write(&self) -> TokenStream2 {
let ident = &self.ident;
quote! {
write!(f, "#{}", #ident)?;
{
let __hash = #ident.to_string();
if !__hash.is_empty() {
write!(f, "#{}", __hash)?;
}
}
}
}