Skip to content

Commit

Permalink
add redirect tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kartva committed Feb 9, 2023
1 parent 79a3ee7 commit 66dc9bd
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions components/content/src/section.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,4 +364,24 @@ Bonjour le monde"#
assert_eq!(section.lang, "fr".to_string());
assert_eq!(section.permalink, "http://a-website.com/fr/subcontent/");
}

#[test]
fn can_redirect_to_external_site() {
let config = Config::default();
let content = r#"
+++
redirect_to = "https://bar.com/something"
+++
Example"#
.to_string();
let res = Section::parse(
Path::new("content/subcontent/_index.md"),
&content,
&config,
&PathBuf::new(),
);
assert!(res.is_ok());
let section = res.unwrap();
assert_eq!(section.meta.redirect_to, Some("https://bar.com/something".to_owned()));
}
}

0 comments on commit 66dc9bd

Please sign in to comment.