Simon Sapin 10 жил өмнө
parent
commit
3f92946af3
1 өөрчлөгдсөн 2 нэмэгдсэн , 2 устгасан
  1. 2 2
      src/lib.rs

+ 2 - 2
src/lib.rs

@@ -361,7 +361,7 @@ impl Url {
     #[inline]
     #[inline]
     pub fn has_authority(&self) -> bool {
     pub fn has_authority(&self) -> bool {
         debug_assert!(self.byte_at(self.scheme_end) == b':');
         debug_assert!(self.byte_at(self.scheme_end) == b':');
-        self.slice(self.scheme_end + 1 ..).starts_with("//")
+        self.slice(self.scheme_end..).starts_with("://")
     }
     }
 
 
     /// Return whether this URL is a cannot-be-a-base URL,
     /// Return whether this URL is a cannot-be-a-base URL,
@@ -378,7 +378,7 @@ impl Url {
     /// as a percent-encoded ASCII string.
     /// as a percent-encoded ASCII string.
     pub fn username(&self) -> &str {
     pub fn username(&self) -> &str {
         if self.has_authority() {
         if self.has_authority() {
-            self.slice(self.scheme_end + 3..self.username_end)
+            self.slice(self.scheme_end + ("://".len() as u32)..self.username_end)
         } else {
         } else {
             ""
             ""
         }
         }