Skip to content

Commit 0e120ce

Browse files
authored
fixup: revert update url.rs
1 parent 1e61d74 commit 0e120ce

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/url.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff 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
610614
pub fn scheme_is_special(scheme: &str) -> bool {
611615
matches!(scheme, "http" | "https" | "ws" | "wss" | "ftp" | "file")

0 commit comments

Comments
 (0)