Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion url/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3086,7 +3086,11 @@ fn file_url_segments_to_pathbuf(

for segment in segments {
bytes.push(b'/');
bytes.extend(percent_decode(segment.as_bytes()));
// `percent_decode(..).into()` yields a `Cow::Borrowed` when the segment
// has nothing to decode (no `%`), which is the common case; copying the
// slice in bulk is much faster than the byte-at-a-time decode iterator.
let decoded: Cow<'_, [u8]> = percent_decode(segment.as_bytes()).into();
bytes.extend_from_slice(&decoded);
}

// A windows drive letter must end with a slash.
Expand Down