Skip to content

Commit 59b6962

Browse files
committed
Hash getter and setter.
1 parent 311ceb8 commit 59b6962

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/quirks.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,14 @@ pub fn hash(url: &Url) -> &str {
270270

271271
/// Setter for https://url.spec.whatwg.org/#dom-url-hash
272272
pub fn set_hash(url: &mut Url, new_hash: &str) {
273-
if url.scheme() != "javascript" {
274-
url.set_fragment(match new_hash {
275-
"" => None,
276-
_ if new_hash.starts_with('#') => Some(&new_hash[1..]),
277-
_ => Some(new_hash),
278-
})
279-
}
273+
url.set_fragment(match new_hash {
274+
// If the given value is the empty string,
275+
// then set context object’s url’s fragment to null and return.
276+
"" => None,
277+
// Let input be the given value with a single leading U+0023 (#) removed, if any.
278+
_ if new_hash.starts_with('#') => Some(&new_hash[1..]),
279+
_ => Some(new_hash),
280+
})
280281
}
281282

282283
fn trim(s: &str) -> &str {

0 commit comments

Comments
 (0)