diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/generate_html.rs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/generate_html.rs b/src/generate_html.rs index cb2f1f3..353d1fb 100644 --- a/src/generate_html.rs +++ b/src/generate_html.rs @@ -510,17 +510,19 @@ fn parse_external_link(label: &str, path: &str, page: &Page, website: &Website) let from = &page; let mut path = path.to_owned(); let mut label = label.to_string(); - 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 let Some(stripped) = path.strip_prefix("mailto:") { + if label.is_empty() { + label = stripped.to_string(); + } + } else if let Some((scheme, stripped)) = path.split_once("://") { + if label.is_empty() { + label = stripped.to_string(); + if !scheme.contains("http") { + label = format!("{scheme}://{label}"); } - break; } - } - if is_internal { + } else { // Check that the linked static file exists. match website.has_static(page, &path) { Some(resolved) => path = resolved, |
