1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:38:10 +00:00

LibWeb: Add leading "#" to window.location.hash if not empty

This commit is contained in:
Linus Groh 2020-05-19 21:36:19 +01:00 committed by Andreas Kling
parent c38c2668da
commit 8a913f336a

View file

@ -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)