summaryrefslogtreecommitdiff
path: root/support/pkgcheck/src/linkcheck.rs
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2022-01-16 03:01:19 +0000
committerNorbert Preining <norbert@preining.info>2022-01-16 03:01:19 +0000
commita574e957682cad50981ddb567c2a106213dc8672 (patch)
treecd02ecf7773fd7bad8e7b6cdb07cf2ff437ba59f /support/pkgcheck/src/linkcheck.rs
parent0cb730e5737ffa35f797eaf75c2613e5ac88617c (diff)
CTAN sync 202201160301
Diffstat (limited to 'support/pkgcheck/src/linkcheck.rs')
-rw-r--r--support/pkgcheck/src/linkcheck.rs20
1 files changed, 18 insertions, 2 deletions
diff --git a/support/pkgcheck/src/linkcheck.rs b/support/pkgcheck/src/linkcheck.rs
index cc7aa36e31..b0b33fb3b2 100644
--- a/support/pkgcheck/src/linkcheck.rs
+++ b/support/pkgcheck/src/linkcheck.rs
@@ -161,6 +161,22 @@ fn get_links(fname: &str) -> Option<Vec<String>> {
None
}
+fn resolve_entities(url: &str) -> String {
+ if !url.contains('&') {
+ return String::from(url);
+ }
+
+ let v = vec![
+ ("&ouml;", "ö"),
+ ("&uuml;", "ü"),
+ ];
+ let mut url_new = String::from(url);
+ for (e,r) in v {
+ url_new = url_new.replace(e, r);
+ }
+ url_new
+}
+
// retrieves links in a string and then checks those links
fn get_links_inner(s: &str) -> Option<Vec<String>> {
let mut finder = LinkFinder::new();
@@ -177,9 +193,9 @@ fn get_links_inner(s: &str) -> Option<Vec<String>> {
}
// This is a workaround to prevent URLs ending with certain characters
- let url = r.trim_end_matches(|c| c == '。' || c == '`');
+ let url = resolve_entities(r.trim_end_matches(|c| c == '。' || c == '`'));
- links.push(String::from(url));
+ links.push(url);
}
if !links.is_empty() {
Some(links)