diff --git a/Tests/LibWeb/Text/expected/HTML/History-pushState-change-query.txt b/Tests/LibWeb/Text/expected/HTML/History-pushState-change-query.txt
new file mode 100644
index 00000000000..0274e41db66
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/History-pushState-change-query.txt
@@ -0,0 +1,3 @@
+Good: changing the query via pushState()
+Good: threw on changing the filename via pushState()
+Good: going back to the original filename
diff --git a/Tests/LibWeb/Text/input/HTML/History-pushState-change-query.html b/Tests/LibWeb/Text/input/HTML/History-pushState-change-query.html
new file mode 100644
index 00000000000..b0154a9eb3e
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/History-pushState-change-query.html
@@ -0,0 +1,24 @@
+
+
diff --git a/Userland/Libraries/LibWeb/HTML/History.cpp b/Userland/Libraries/LibWeb/HTML/History.cpp
index c3fa2cde3fb..ca34ed42516 100644
--- a/Userland/Libraries/LibWeb/HTML/History.cpp
+++ b/Userland/Libraries/LibWeb/HTML/History.cpp
@@ -148,9 +148,12 @@ bool can_have_its_url_rewritten(DOM::Document const& document, URL::URL const& t
// 4. If targetURL's scheme is "file", and targetURL and documentURL differ in their path component,
// then return false. (Differences in query and fragment are allowed for file: URLs.)
+ // FIXME: There's a bug in the spec here. We should return true if the scheme is "file" and the path components don't differ.
+ // Spec bug: https://github.com/whatwg/html/issues/10551
bool path_components_match = target_url.paths() == document_url.paths();
- if (target_url.scheme() == "file"sv && !path_components_match)
- return false;
+ if (target_url.scheme() == "file"sv) {
+ return path_components_match;
+ }
// 5. If targetURL and documentURL differ in their path component or query components, then return false.
// (Only differences in fragment are allowed for other types of URLs.)