1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:27:45 +00:00

LibWeb: Implement ad-hoc steps to allow LibWeb to load resource:// URLs

The resource:// scheme is used for Core::Resource files. Currently, any
users of resource:// URLs in Ladybird must manually create the Resource
and extract its data. This will allow for passing the resource:// URL
along for LibWeb to handle.
This commit is contained in:
Timothy Flynn 2023-12-23 15:42:05 -05:00 committed by Andreas Kling
parent 48f39f0555
commit e511a264fe
3 changed files with 40 additions and 8 deletions

View file

@ -832,6 +832,10 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> scheme_fetch(JS::Realm& r
// Return the result of running HTTP fetch given fetchParams.
return http_fetch(realm, fetch_params);
}
// AD-HOC: "resource"
else if (request->current_url().scheme() == "resource"sv) {
return TRY(nonstandard_resource_loader_file_or_http_network_fetch(realm, fetch_params));
}
// 4. Return a network error.
auto message = request->current_url().scheme() == "about"sv

View file

@ -27,7 +27,10 @@ inline constexpr Array HTTP_SCHEMES = {
// https://fetch.spec.whatwg.org/#fetch-scheme
// A fetch scheme is "about", "blob", "data", "file", or an HTTP(S) scheme.
inline constexpr Array FETCH_SCHEMES = {
"about"sv, "blob"sv, "data"sv, "file"sv, "http"sv, "https"sv
"about"sv, "blob"sv, "data"sv, "file"sv, "http"sv, "https"sv,
// AD-HOC: Internal fetch schemes:
"resource"sv
};
[[nodiscard]] bool is_local_url(AK::URL const&);