Skip to content

Commit

Permalink
Ensure hrefs have a trailing slash /
Browse files Browse the repository at this point in the history
  • Loading branch information
arranf committed Jun 17, 2019
1 parent c085330 commit 7c24ef0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
3 changes: 0 additions & 3 deletions src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ pub const FORWARD_SLASH: &str = "/";
pub const EMPTY_STRING: &str = "";
pub const TOML_FENCE: &str = "+++";
pub const YAML_FENCE: &str = "---";
// TODO: Fix this being super naive. JSON can have nested objects - and will fail here
// pub const JSON_FENCE_OPEN: &str = "{";
// pub const JSON_FENCE_CLOSE: &str = "}";
pub const MARKDOWN_EXTENSION: &str = "md";

pub const DRAFT: &str = "draft";
Expand Down
3 changes: 2 additions & 1 deletion src/page_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ impl PageIndex {
&file_location.relative_directory_to_content,
FORWARD_SLASH,
slug,
FORWARD_SLASH,
]
.join(EMPTY_STRING);

Expand Down Expand Up @@ -124,7 +125,7 @@ mod tests {
&build_file_location(),
);
assert!(page_index.is_ok());
assert_eq!(page_index.unwrap().href, "/post/my-example-post")
assert_eq!(page_index.unwrap().href, "/post/my-example-post/")
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ tags:
let mut buf_reader = BufReader::new(output_file);
let mut read_back = String::new();
buf_reader.read_to_string(&mut read_back)?;
let expected = r#"[{"title":"What You Can Achieve In a Year","href":"//what-you-can-achieve-in-a-year","date":"2019-02-15T20:01:39Z","content":"Jon Edmiston\n","tags":["Blog","RSS","Blogging"]}]"#;
let expected = r#"[{"title":"What You Can Achieve In a Year","href":"//what-you-can-achieve-in-a-year/","date":"2019-02-15T20:01:39Z","content":"Jon Edmiston\n","tags":["Blog","RSS","Blogging"]}]"#;
assert_eq!(read_back, expected);

remove_file(output_file_path)?;
Expand Down Expand Up @@ -339,7 +339,7 @@ Contents here
let mut buf_reader = BufReader::new(output_file);
let mut read_back = String::new();
buf_reader.read_to_string(&mut read_back)?;
let expected = r#"[{"title":"Replacing Sed/Awk With Amber","href":"//replacing-awk-sed-with-amber","date":"2019-01-25T07:52:40Z","content":"Contents here","tags":["Rust","Bash","Awk","Sed","Amber","Code Search","Replace","Unix"]}]"#;
let expected = r#"[{"title":"Replacing Sed/Awk With Amber","href":"//replacing-awk-sed-with-amber/","date":"2019-01-25T07:52:40Z","content":"Contents here","tags":["Rust","Bash","Awk","Sed","Amber","Code Search","Replace","Unix"]}]"#;
assert_eq!(read_back, expected);

remove_file(output_file_path)?;
Expand Down

0 comments on commit 7c24ef0

Please sign in to comment.