File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -602,10 +602,14 @@ fn is_punnycode_domain(lib_url: &Url, domain: &str) -> bool {
602602 scheme_is_special ( lib_url. scheme ( ) ) && domain. split ( '.' ) . any ( |part| part. starts_with ( PUNYCODE_PREFIX ) )
603603}
604604
605- fn encode_userinfo_component ( value : & str ) -> impl Display {
606- utf8_percent_encode ( value, NON_ALPHANUMERIC )
605+ fn encode_userinfo_component ( value : & str ) -> Cow < ' _ , str > {
606+ let encoded = percent_encode ( value. as_bytes ( ) , NON_ALPHANUMERIC ) . to_string ( ) ;
607+ if encoded == value {
608+ Cow :: Borrowed ( value)
609+ } else {
610+ Cow :: Owned ( encoded)
611+ }
607612}
608-
609613// based on https://github.com/servo/rust-url/blob/1c1e406874b3d2aa6f36c5d2f3a5c2ea74af9efb/url/src/parser.rs#L161-L167
610614pub fn scheme_is_special ( scheme : & str ) -> bool {
611615 matches ! ( scheme, "http" | "https" | "ws" | "wss" | "ftp" | "file" )
You can’t perform that action at this time.
0 commit comments