mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:27:43 +00:00
LibWeb: Add definitions from '2.1. URL' in the Fetch spec
This commit is contained in:
parent
de74ba587f
commit
7c2c9b6859
3 changed files with 53 additions and 0 deletions
|
@ -118,6 +118,7 @@ set(SOURCES
|
||||||
Encoding/TextDecoder.cpp
|
Encoding/TextDecoder.cpp
|
||||||
Encoding/TextEncoder.cpp
|
Encoding/TextEncoder.cpp
|
||||||
Fetch/AbstractOperations.cpp
|
Fetch/AbstractOperations.cpp
|
||||||
|
Fetch/Infrastructure/URL.cpp
|
||||||
FontCache.cpp
|
FontCache.cpp
|
||||||
Geometry/DOMRectList.cpp
|
Geometry/DOMRectList.cpp
|
||||||
HTML/AttributeNames.cpp
|
HTML/AttributeNames.cpp
|
||||||
|
|
18
Userland/Libraries/LibWeb/Fetch/Infrastructure/URL.cpp
Normal file
18
Userland/Libraries/LibWeb/Fetch/Infrastructure/URL.cpp
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/Fetch/Infrastructure/URL.h>
|
||||||
|
|
||||||
|
namespace Web::Fetch {
|
||||||
|
|
||||||
|
// https://fetch.spec.whatwg.org/#is-local
|
||||||
|
bool is_local_url(AK::URL const& url)
|
||||||
|
{
|
||||||
|
// A URL is local if its scheme is a local scheme.
|
||||||
|
return any_of(LOCAL_SCHEMES, [&](auto scheme) { return url.scheme() == scheme; });
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
34
Userland/Libraries/LibWeb/Fetch/Infrastructure/URL.h
Normal file
34
Userland/Libraries/LibWeb/Fetch/Infrastructure/URL.h
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/Array.h>
|
||||||
|
#include <AK/URL.h>
|
||||||
|
|
||||||
|
namespace Web::Fetch {
|
||||||
|
|
||||||
|
// https://fetch.spec.whatwg.org/#local-scheme
|
||||||
|
// A local scheme is "about", "blob", or "data".
|
||||||
|
inline constexpr Array LOCAL_SCHEMES = {
|
||||||
|
"about"sv, "blob"sv, "data"sv
|
||||||
|
};
|
||||||
|
|
||||||
|
// https://fetch.spec.whatwg.org/#http-scheme
|
||||||
|
// An HTTP(S) scheme is "http" or "https".
|
||||||
|
inline constexpr Array HTTP_SCHEMES = {
|
||||||
|
"http"sv, "https"sv
|
||||||
|
};
|
||||||
|
|
||||||
|
// 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
|
||||||
|
};
|
||||||
|
|
||||||
|
[[nodiscard]] bool is_local_url(AK::URL const&);
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue