From 05e53b5fd32ab6d03da0b753fe29ee67094b433c Mon Sep 17 00:00:00 2001 From: ronak69 Date: Mon, 29 Jan 2024 15:47:21 +0000 Subject: [PATCH] LibWeb: Use file's URL as document's URL when loading markdown files A markdown file gets loaded as an inline content document by `create_document_for_inline_content()`, for which the default document URL is "about:error". That breaks the fragment links. Overriding "about:error" URL by passing the URL of the just loaded markdown file as an argument to `HTMLParser::run()` ensures that the URL of the document is as expected. --- Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp b/Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp index 5e4c25af8e..9a32cee8ba 100644 --- a/Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp +++ b/Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp @@ -78,7 +78,7 @@ static WebIDL::ExceptionOr> load_markdown_docume return; auto parser = HTML::HTMLParser::create(document, markdown_document->render_to_html(extra_head_contents), "utf-8"); - parser->run(document.url()); + parser->run(url); }; auto process_body_error = [](auto) {