Skip to content

web search done right

there exists a shitton of double slash links on the internet

Mikkel Denker9604fb2d8a62
diff --git a/core/src/webpage/url.rs b/core/src/webpage/url.rs
index c9f3070d..55883206 100644
--- a/core/src/webpage/url.rs
+++ b/core/src/webpage/url.rs
@@ -194,6 +194,10 @@ impl Url {
}
pub fn full(&self) -> String {
+ if self.0.starts_with("//") {
+ return "https:".to_string() + self.0.as_str();
+ }
+
if self.find_protocol_end() == 0 {
"https://".to_string() + self.0.as_str()
} else {
@@ -300,6 +304,7 @@ mod tests {
assert_eq!(url.domain(), "dailymail.co.uk");
assert_eq!(url.domain_name(), "dailymail");
assert_eq!(url.site(), "scripts.dailymail.co.uk");
+ assert_eq!(url.full(), "https://scripts.dailymail.co.uk");
}
#[test]