mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-16 14:32:18 +00:00
LibWeb: Implement "Resolve a Blob URL"
Which performs a lookup to find a blob (if any) corresponding to the given blob URL.
This commit is contained in:
parent
c071720430
commit
ec381c122e
Notes:
sideshowbarker
2024-07-18 00:34:07 +09:00
Author: https://github.com/shannonbooth
Commit: ec381c122e
Pull-request: https://github.com/SerenityOS/serenity/pull/24220
Reviewed-by: https://github.com/kennethmyhra
2 changed files with 19 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
* Copyright (c) 2024, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -106,4 +107,20 @@ void run_unloading_cleanup_steps(JS::NonnullGCPtr<DOM::Document> document)
|
|||
});
|
||||
}
|
||||
|
||||
// https://w3c.github.io/FileAPI/#blob-url-resolve
|
||||
Optional<BlobURLEntry> resolve_a_blob_url(URL::URL const& url)
|
||||
{
|
||||
// 1. Assert: url’s scheme is "blob".
|
||||
VERIFY(url.scheme() == "blob"sv);
|
||||
|
||||
// 2. Let store be the user agent’s blob URL store.
|
||||
auto& store = blob_url_store();
|
||||
|
||||
// 3. Let url string be the result of serializing url with the exclude fragment flag set.
|
||||
auto url_string = MUST(String::from_byte_string(url.serialize(URL::ExcludeFragment::Yes)));
|
||||
|
||||
// 4. If store[url string] exists, return store[url string]; otherwise return failure.
|
||||
return store.get(url_string);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <AK/String.h>
|
||||
#include <LibJS/Heap/GCPtr.h>
|
||||
#include <LibJS/Heap/Handle.h>
|
||||
#include <LibURL/Forward.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
namespace Web::FileAPI {
|
||||
|
@ -27,6 +28,7 @@ BlobURLStore& blob_url_store();
|
|||
ErrorOr<String> generate_new_blob_url();
|
||||
ErrorOr<String> add_entry_to_blob_url_store(JS::NonnullGCPtr<Blob> object);
|
||||
ErrorOr<void> remove_entry_from_blob_url_store(StringView url);
|
||||
Optional<BlobURLEntry> resolve_a_blob_url(URL::URL const&);
|
||||
|
||||
void run_unloading_cleanup_steps(JS::NonnullGCPtr<DOM::Document>);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue