Skip to content

Commit c70d180

Browse files
committed
33 tests to go.
1 parent 153ff7c commit c70d180

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/quirks.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,13 @@ pub fn host(url: &Url) -> &str {
9999

100100
/// Setter for https://url.spec.whatwg.org/#dom-url-host
101101
pub fn set_host(url: &mut Url, new_host: &str) -> Result<(), ()> {
102+
// If context object’s url’s cannot-be-a-base-URL flag is set, then return.
103+
if url.cannot_be_a_base() {
104+
return Err(());
105+
}
102106
let host;
103107
let opt_port;
104108
{
105-
// If context object’s url’s cannot-be-a-base-URL flag is set, then return.
106-
if url.cannot_be_a_base() {
107-
return Err(());
108-
}
109-
110109
let scheme = url.scheme();
111110
let result = Parser::parse_host(Input::new(new_host), SchemeType::from(scheme));
112111
match result {
@@ -202,18 +201,19 @@ pub fn pathname(url: &Url) -> &str {
202201

203202
/// Setter for https://url.spec.whatwg.org/#dom-url-pathname
204203
pub fn set_pathname(url: &mut Url, new_pathname: &str) {
205-
if !url.cannot_be_a_base() && !new_pathname.is_empty() {
206-
if !SchemeType::from(url.scheme()).is_special()
204+
if !url.cannot_be_a_base() {
205+
return;
206+
}
207+
if !SchemeType::from(url.scheme()).is_special()
207208
|| Some('/') == new_pathname.chars().nth(0)
208209
// \\ is a segment delimiter for 'special' URLs"
209210
|| Some('\\') == new_pathname.chars().nth(0)
210-
{
211-
url.set_path(new_pathname)
212-
} else {
213-
let mut path_to_set = String::from("/");
214-
path_to_set.push_str(new_pathname);
215-
url.set_path(&path_to_set)
216-
}
211+
{
212+
url.set_path(new_pathname)
213+
} else {
214+
let mut path_to_set = String::from("/");
215+
path_to_set.push_str(new_pathname);
216+
url.set_path(&path_to_set)
217217
}
218218
}
219219

0 commit comments

Comments
 (0)