Serenity Operating System
at master 33 lines 987 B view raw
1/* 2 * Copyright (c) 2022, Linus Groh <linusg@serenityos.org> 3 * Copyright (c) 2022, Andreas Kling <kling@serenityos.org> 4 * 5 * SPDX-License-Identifier: BSD-2-Clause 6 */ 7 8#include <LibWeb/Fetch/Infrastructure/URL.h> 9 10namespace Web::Fetch::Infrastructure { 11 12// https://fetch.spec.whatwg.org/#is-local 13bool is_local_url(AK::URL const& url) 14{ 15 // A URL is local if its scheme is a local scheme. 16 return any_of(LOCAL_SCHEMES, [&](auto scheme) { return url.scheme() == scheme; }); 17} 18 19// https://fetch.spec.whatwg.org/#fetch-scheme 20bool is_fetch_scheme(StringView scheme) 21{ 22 // A fetch scheme is "about", "blob", "data", "file", or an HTTP(S) scheme. 23 return any_of(FETCH_SCHEMES, [&](auto fetch_scheme) { return scheme == fetch_scheme; }); 24} 25 26// https://fetch.spec.whatwg.org/#http-scheme 27bool is_http_or_https_scheme(StringView scheme) 28{ 29 // An HTTP(S) scheme is "http" or "https". 30 return any_of(HTTP_SCHEMES, [&](auto http_scheme) { return scheme == http_scheme; }); 31} 32 33}