summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/generate_html.rs19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/generate_html.rs b/src/generate_html.rs
index 9533410..86341e6 100644
--- a/src/generate_html.rs
+++ b/src/generate_html.rs
@@ -292,7 +292,17 @@ fn line_to_html(line: &Line, page: &Page, website: &Website) -> String {
let mut path = path.to_owned();
let mut label = label.to_string();
- if !path.contains("://") {
+ let mut is_internal = true;
+ for protocol in ["mailto:", "http://", "https://"] {
+ if let Some(stripped) = path.strip_prefix(protocol) {
+ is_internal = false;
+ if label.is_empty() {
+ label = stripped.to_string();
+ }
+ }
+
+ }
+ if is_internal {
// Check that the linked static file exists.
match website.has_static(page, &path) {
Some(resolved_path) => path = resolved_path,
@@ -305,13 +315,8 @@ fn line_to_html(line: &Line, page: &Page, website: &Website) -> String {
None => path.clone(),
};
}
- } else if label.is_empty() {
- for protocol in ["mailto://", "http://", "https://"] {
- if let Some(stripped) = path.strip_prefix(protocol) {
- label = stripped.to_string();
- }
- }
}
+
let label = sanitize_text(&label);
html.push_str(&format!("<a href='{path}' class='external'>{label}</a>"));
}