From 6caacfec85cf0c2f0d55e734d8e1cf034926c9cb Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Tue, 19 May 2020 21:40:30 +0100 Subject: [PATCH] LibWeb: Add leading "?" to window.location.search if not empty --- Libraries/LibWeb/Bindings/LocationObject.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Libraries/LibWeb/Bindings/LocationObject.cpp b/Libraries/LibWeb/Bindings/LocationObject.cpp index 90cc8a07d6..831bd5df08 100644 --- a/Libraries/LibWeb/Bindings/LocationObject.cpp +++ b/Libraries/LibWeb/Bindings/LocationObject.cpp @@ -106,7 +106,13 @@ JS::Value LocationObject::hash_getter(JS::Interpreter& interpreter) JS::Value LocationObject::search_getter(JS::Interpreter& interpreter) { auto& window = static_cast(interpreter.global_object()); - return JS::js_string(interpreter, window.impl().document().url().query()); + auto query = window.impl().document().url().query(); + if (!query.length()) + return JS::js_string(interpreter, ""); + StringBuilder builder; + builder.append('?'); + builder.append(query); + return JS::js_string(interpreter, builder.to_string()); } JS::Value LocationObject::protocol_getter(JS::Interpreter& interpreter)