From d7d7d95a88933981097e6015fa61f0dee4e7a9d2 Mon Sep 17 00:00:00 2001 From: soutade Date: Tue, 21 Jan 2025 14:17:59 +0100 Subject: [PATCH] Handle permalink with anchor (doesn't add trailing slash) (#2779) Co-authored-by: Gregory Soutade --- components/config/src/config/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/config/src/config/mod.rs b/components/config/src/config/mod.rs index b8deb6c44f..604d6fbb78 100644 --- a/components/config/src/config/mod.rs +++ b/components/config/src/config/mod.rs @@ -204,6 +204,7 @@ impl Config { let trailing_bit = if path.ends_with('/') || self.feed_filenames.iter().any(|feed_filename| path.ends_with(feed_filename)) || path.is_empty() + || path.contains("#") { "" } else { @@ -584,6 +585,13 @@ hello = "world" assert_eq!(config.make_permalink("atom.xml"), "http://vincent.is/atom.xml"); } + // https://github.com/getzola/zola/issues/2676 + #[test] + fn permalink_with_anchor() { + let config = Config { base_url: "http://vincent.is".to_string(), ..Default::default() }; + assert_eq!(config.make_permalink("/about#me"), "http://vincent.is/about#me"); + } + #[test] fn can_merge_with_theme_data_and_preserve_config_value() { let config_str = r#"