Skip to content

Commit 05c0640

Browse files
bplaattrflynn89
authored andcommitted
Ladybird+LibWeb: Add about scheme support for internal pages
1 parent c0acb29 commit 05c0640

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

Base/res/ladybird/about.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>About URLs</title>
6+
</head>
7+
<body>
8+
<h1>List of About URLs</h1>
9+
<ul>
10+
<li><a href="about:about">about:about</a></li>
11+
<li><a href="about:newtab">about:newtab</a></li>
12+
</ul>
13+
</body>
14+
</html>

Meta/gn/secondary/Ladybird/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ if (current_os == "mac") {
294294

295295
bundle_data("ladybird_web_resources") {
296296
sources = [
297+
"//Base/res/ladybird/about.html",
297298
"//Base/res/ladybird/inspector.css",
298299
"//Base/res/ladybird/inspector.js",
299300
"//Base/res/ladybird/newtab.html",

Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,9 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> scheme_fetch(JS::Realm& r
718718
response->set_body(MUST(Infrastructure::byte_sequence_as_body(realm, ""sv.bytes())));
719719
return PendingResponse::create(vm, request, response);
720720
}
721+
722+
// FIXME: This is actually wrong, see note above.
723+
return TRY(nonstandard_resource_loader_file_or_http_network_fetch(realm, fetch_params));
721724
}
722725
// -> "blob"
723726
else if (request->current_url().scheme() == "blob"sv) {

Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,14 @@ void ResourceLoader::load(LoadRequest& request, SuccessCallback success_callback
230230
HashMap<ByteString, ByteString, CaseInsensitiveStringTraits> response_headers;
231231
response_headers.set("Content-Type", "text/html; charset=UTF-8");
232232

233+
// Other about static HTML pages
234+
auto resource = Core::Resource::load_from_uri(MUST(String::formatted("resource://ladybird/{}.html", url.path_segment_at_index(0))));
235+
if (!resource.is_error()) {
236+
auto data = resource.value()->data();
237+
success_callback(data, response_headers, {});
238+
return;
239+
}
240+
233241
Platform::EventLoopPlugin::the().deferred_invoke([success_callback = move(success_callback), response_headers = move(response_headers)] {
234242
success_callback(ByteString::empty().to_byte_buffer(), response_headers, {});
235243
});

0 commit comments

Comments
 (0)