remove /jump.php track links

This commit is contained in:
2022-03-02 22:49:42 +08:00
parent ded0e77956
commit 41bc589050
5 changed files with 34 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
use crate::gettext;
use crate::pixiv_link::remove_track;
use html_parser::Dom;
use html_parser::Node;
use std::collections::HashMap;
@@ -98,7 +99,8 @@ impl DescriptionParser {
if href.is_some() {
let href = href.unwrap();
if href.is_some() {
node.add_attr("href", href.as_ref().unwrap());
let link = remove_track(href.as_ref().unwrap());
node.add_attr("href", link.as_str());
}
}
}
@@ -171,4 +173,8 @@ fn test_parse_description() {
Some(String::from("a [a\n[bc](a.com)d](b.com)\ndata")),
parse_description("a <a href=\"b.com\">a<br/><a href=\"a.com\">bc</a>d</a><br>data")
);
assert_eq!(
Some(String::from("https://a.com")),
parse_description("<a href=\"/jump.php?https%3A%2F%2Fa.com\">https://a.com</a>")
)
}