Fix backslash url rewriting and add tests for rewrite_urls. (#461)

* Fix backslash url rewriting.

Add test for rewrite_urls.

Fixes #281.

* Update to v0.22.5

Co-authored-by: spikecodes <19519553+spikecodes@users.noreply.github.com>
This commit is contained in:
mikupls 2022-03-26 21:26:30 +01:00 committed by GitHub
parent ed11135af8
commit eb6c5e5e1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 8 deletions

View file

@ -102,7 +102,7 @@ async fn parse_post(json: &serde_json::Value) -> Post {
let body = if val(post, "removed_by_category") == "moderator" {
format!("<div class=\"md\"><p>[removed] — <a href=\"https://www.reveddit.com{}\">view removed post</a></p></div>", permalink)
} else {
rewrite_urls(&val(post, "selftext_html")).replace("\\", "")
rewrite_urls(&val(post, "selftext_html"))
};
// Build a post using data parsed from Reddit post API
@ -201,7 +201,7 @@ fn parse_comments(json: &serde_json::Value, post_link: &str, post_author: &str,
let body = if val(&comment, "author") == "[deleted]" && val(&comment, "body") == "[removed]" {
format!("<div class=\"md\"><p>[removed] — <a href=\"https://www.reveddit.com{}{}\">view removed comment</a></p></div>", post_link, id)
} else {
rewrite_urls(&val(&comment, "body_html")).to_string()
rewrite_urls(&val(&comment, "body_html"))
};
let author = Author {