Skip to content

Commit 902fd3a

Browse files
pqcfoxKeats
authored andcommitted
Allow external links to start with "www.*" (#2100)
* Make www.* URLs considered valid external links * Tweak description of is_external_link
1 parent bc27c01 commit 902fd3a

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

components/markdown/src/markdown.rs

+1
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,7 @@ mod tests {
593593
fn test_is_external_link() {
594594
assert!(is_external_link("http://example.com/"));
595595
assert!(is_external_link("https://example.com/"));
596+
assert!(is_external_link("www.example.com"));
596597
assert!(is_external_link("https://example.com/index.html#introduction"));
597598

598599
assert!(!is_external_link("mailto:[email protected]"));

components/utils/src/net.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub fn port_is_available(port: u16) -> bool {
1010
TcpListener::bind(("127.0.0.1", port)).is_ok()
1111
}
1212

13-
/// Returns whether a link starts with an HTTP(s) scheme.
13+
/// Returns whether a link starts with an HTTP(s) scheme or "www.".
1414
pub fn is_external_link(link: &str) -> bool {
15-
link.starts_with("http:") || link.starts_with("https:")
15+
link.starts_with("http:") || link.starts_with("https:") || link.starts_with("www.")
1616
}

0 commit comments

Comments
 (0)