summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-05-19 21:36:19 +0100
committerAndreas Kling <kling@serenityos.org>2020-05-20 08:30:22 +0200
commit8a913f336ab54231f858b727fe43d5d88dc2a771 (patch)
tree0460aa6d2e15a2a0686d1ff01ee6c5d040f6bc38
parentc38c2668da3fff187c7eeae3043322535aa60770 (diff)
downloadserenity-8a913f336ab54231f858b727fe43d5d88dc2a771.zip
LibWeb: Add leading "#" to window.location.hash if not empty
-rw-r--r--Libraries/LibWeb/Bindings/LocationObject.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/Libraries/LibWeb/Bindings/LocationObject.cpp b/Libraries/LibWeb/Bindings/LocationObject.cpp
index 0b3b3df9b2..90cc8a07d6 100644
--- a/Libraries/LibWeb/Bindings/LocationObject.cpp
+++ b/Libraries/LibWeb/Bindings/LocationObject.cpp
@@ -94,7 +94,13 @@ JS::Value LocationObject::host_getter(JS::Interpreter& interpreter)
JS::Value LocationObject::hash_getter(JS::Interpreter& interpreter)
{
auto& window = static_cast<WindowObject&>(interpreter.global_object());
- return JS::js_string(interpreter, window.impl().document().url().fragment());
+ auto fragment = window.impl().document().url().fragment();
+ if (!fragment.length())
+ return JS::js_string(interpreter, "");
+ StringBuilder builder;
+ builder.append('#');
+ builder.append(fragment);
+ return JS::js_string(interpreter, builder.to_string());
}
JS::Value LocationObject::search_getter(JS::Interpreter& interpreter)