Skip to content

Commit f2c906a

Browse files
committed
A special url always has a path. A path always starts with '/'
1 parent d1d56c3 commit f2c906a

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/parser.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -798,8 +798,24 @@ impl<'a> Parser<'a> {
798798
self.serialization.push_str(before_query);
799799
// FIXME spec says just "remove last entry", not the "pop" algorithm
800800
self.pop_path(scheme_type, base_url.path_start as usize);
801-
let remaining =
802-
self.parse_path(scheme_type, &mut true, base_url.path_start as usize, input);
801+
// A special url always has a path.
802+
// A path always starts with '/'
803+
if self.serialization.len() == base_url.path_start as usize {
804+
if SchemeType::from(base_url.scheme()).is_special() || !input.is_empty() {
805+
self.serialization.push('/');
806+
}
807+
}
808+
let remaining = match input.split_first() {
809+
(Some('/'), remaining) => self.parse_path(
810+
scheme_type,
811+
&mut true,
812+
base_url.path_start as usize,
813+
remaining,
814+
),
815+
_ => {
816+
self.parse_path(scheme_type, &mut true, base_url.path_start as usize, input)
817+
}
818+
};
803819
self.with_query_and_fragment(
804820
scheme_type,
805821
base_url.scheme_end,

0 commit comments

Comments
 (0)