Do not have trailing slash for rss.xml

Closes #486
This commit is contained in:
Vincent Prouillet 2018-10-18 18:09:31 +02:00
parent 83b04a561c
commit dffd39aa8f
2 changed files with 10 additions and 1 deletions

View file

@ -32,6 +32,7 @@ Tera function
sections up to the index to be used with the `get_section` Tera function
- Add a `load_data` Tera function to load local CSV/TOML/JSON files
- Add `relative_path` to pages and sections in templates
- Do not have a trailing slash for the RSS permalinks
## 0.4.2 (2018-09-03)

View file

@ -189,7 +189,7 @@ impl Config {
/// Makes a url, taking into account that the base url might have a trailing slash
pub fn make_permalink(&self, path: &str) -> String {
let trailing_bit = if path.ends_with('/') || path.is_empty() {
let trailing_bit = if path.ends_with('/') || path.ends_with("rss.xml") || path.is_empty() {
""
} else {
"/"
@ -366,6 +366,14 @@ hello = "world"
);
}
// https://github.com/Keats/gutenberg/issues/486
#[test]
fn doesnt_add_trailing_slash_to_rss() {
let mut config = Config::default();
config.base_url = "http://vincent.is/".to_string();
assert_eq!(config.make_permalink("rss.xml"), "http://vincent.is/rss.xml");
}
#[test]
fn can_merge_with_theme_data_and_preserve_config_value() {
let config_str = r#"