LibWeb: Attach blob to URL on DOMURL::parse

On a non-basic URL parse, we are meant to perform a lookup on the blob
URL registry and attach any blob to that URL if present. Now - we do
that :^)
This commit is contained in:
Shannon Booth 2024-05-05 20:37:08 +12:00 committed by Andrew Kaster
commit 2457fdc7a4
Notes: sideshowbarker 2024-07-16 20:39:14 +09:00

View file

@ -575,14 +575,20 @@ URL::URL parse(StringView input, Optional<URL::URL> const& base_url)
if (!url.is_valid())
return {};
// 3. If urls scheme is not "blob",
// 3. If urls scheme is not "blob", return url.
if (url.scheme() != "blob")
return url;
// FIXME: 4. Set urls blob URL entry to the result of resolving the blob URL url,
// FIXME: 5. if that did not return failure, and null otherwise.
// 4. Set urls blob URL entry to the result of resolving the blob URL url, if that did not return failure, and null otherwise.
auto blob_url_entry = FileAPI::resolve_a_blob_url(url);
if (blob_url_entry.has_value()) {
url.set_blob_url_entry(URL::BlobURLEntry {
.type = blob_url_entry->object->type(),
.byte_buffer = MUST(ByteBuffer::copy(blob_url_entry->object->bytes())),
});
}
// 6. Return url
// 5. Return url
return url;
}