From 847589404bb72b725a1fa65c8cbdf58d9761ae5d Mon Sep 17 00:00:00 2001 From: Luke Wilde Date: Fri, 1 Aug 2025 19:22:32 +0100 Subject: [PATCH] LibWeb: Set filename of module scripts to full URL instead of basename Atlassian login gets the base URL for its module scripts by throwing an error and pulling out the current script's URL from error.stack with regex. Since we only returned a basename for module scripts, it would fail to match and try and use `/` as a base URL (because it does [matched_string] + "/"), which is not a valid base URL. --- Libraries/LibWeb/HTML/Scripting/Fetching.cpp | 2 +- .../error-stack-must-contain-full-url.txt | 11 +++++ .../error-stack-must-contain-full-url.html | 43 +++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Text/expected/error-stack-must-contain-full-url.txt create mode 100644 Tests/LibWeb/Text/input/error-stack-must-contain-full-url.html diff --git a/Libraries/LibWeb/HTML/Scripting/Fetching.cpp b/Libraries/LibWeb/HTML/Scripting/Fetching.cpp index 7a52be21d6b..36a203b0cd7 100644 --- a/Libraries/LibWeb/HTML/Scripting/Fetching.cpp +++ b/Libraries/LibWeb/HTML/Scripting/Fetching.cpp @@ -713,7 +713,7 @@ void fetch_single_module_script(JS::Realm& realm, // 7. If mimeType is a JavaScript MIME type and moduleType is "javascript", then set moduleScript to the result of creating a JavaScript module script given sourceText, moduleMapRealm, response's URL, and options. // FIXME: Pass options. if (mime_type.has_value() && mime_type->is_javascript() && module_type == "javascript") - module_script = JavaScriptModuleScript::create(url.basename(), source_text, module_map_realm, response->url().value_or({})).release_value_but_fixme_should_propagate_errors(); + module_script = JavaScriptModuleScript::create(url.to_byte_string(), source_text, module_map_realm, response->url().value_or({})).release_value_but_fixme_should_propagate_errors(); // FIXME: 8. If the MIME type essence of mimeType is "text/css" and moduleType is "css", then set moduleScript to the result of creating a CSS module script given sourceText and settingsObject. // FIXME: 9. If mimeType is a JSON MIME type and moduleType is "json", then set moduleScript to the result of creating a JSON module script given sourceText and settingsObject. diff --git a/Tests/LibWeb/Text/expected/error-stack-must-contain-full-url.txt b/Tests/LibWeb/Text/expected/error-stack-must-contain-full-url.txt new file mode 100644 index 00000000000..2d1ab6eb42d --- /dev/null +++ b/Tests/LibWeb/Text/expected/error-stack-must-contain-full-url.txt @@ -0,0 +1,11 @@ +classic: Error + at Error + at blob:file:///[flaky-uuid-replaced]:3:36 + +module: Error + at Error + at blob:file:///[flaky-uuid-replaced]:3:36 + at + at + at + diff --git a/Tests/LibWeb/Text/input/error-stack-must-contain-full-url.html b/Tests/LibWeb/Text/input/error-stack-must-contain-full-url.html new file mode 100644 index 00000000000..867a94c79ed --- /dev/null +++ b/Tests/LibWeb/Text/input/error-stack-must-contain-full-url.html @@ -0,0 +1,43 @@ + + +
+