Jeremy Lempereur 7 лет назад
Родитель
Сommit
26ccc0d6ea
1 измененных файлов с 8 добавлено и 7 удалено
  1. 8 7
      src/quirks.rs

+ 8 - 7
src/quirks.rs

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