URL.cpp 987 B

123456789101112131415161718192021222324252627282930313233
  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. #include <LibWeb/Fetch/Infrastructure/URL.h>
  8. namespace Web::Fetch::Infrastructure {
  9. // https://fetch.spec.whatwg.org/#is-local
  10. bool is_local_url(AK::URL const& url)
  11. {
  12. // A URL is local if its scheme is a local scheme.
  13. return any_of(LOCAL_SCHEMES, [&](auto scheme) { return url.scheme() == scheme; });
  14. }
  15. // https://fetch.spec.whatwg.org/#fetch-scheme
  16. bool is_fetch_scheme(StringView scheme)
  17. {
  18. // A fetch scheme is "about", "blob", "data", "file", or an HTTP(S) scheme.
  19. return any_of(FETCH_SCHEMES, [&](auto fetch_scheme) { return scheme == fetch_scheme; });
  20. }
  21. // https://fetch.spec.whatwg.org/#http-scheme
  22. bool is_http_or_https_scheme(StringView scheme)
  23. {
  24. // An HTTP(S) scheme is "http" or "https".
  25. return any_of(HTTP_SCHEMES, [&](auto http_scheme) { return scheme == http_scheme; });
  26. }
  27. }