Skip to content

Commit fbfd2e6

Browse files
committed
Hash getter and setter.
1 parent 753eb40 commit fbfd2e6

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/quirks.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,14 @@ pub fn hash(url: &Url) -> &str {
259259

260260
/// Setter for https://url.spec.whatwg.org/#dom-url-hash
261261
pub fn set_hash(url: &mut Url, new_hash: &str) {
262-
if url.scheme() != "javascript" {
263-
url.set_fragment(match new_hash {
264-
"" => None,
265-
_ if new_hash.starts_with('#') => Some(&new_hash[1..]),
266-
_ => Some(new_hash),
267-
})
268-
}
262+
url.set_fragment(match new_hash {
263+
// If the given value is the empty string,
264+
// then set context object’s url’s fragment to null and return.
265+
"" => None,
266+
// Let input be the given value with a single leading U+0023 (#) removed, if any.
267+
_ if new_hash.starts_with('#') => Some(&new_hash[1..]),
268+
_ => Some(new_hash),
269+
})
269270
}
270271

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

0 commit comments

Comments
 (0)