mirror of
https://github.com/RGBCube/serenity
synced 2025-05-24 06:05:08 +00:00

This is meant to serve as the method all Ladybird chromes can use to highlight the eTLD+1 substring of the URL. It uses the Public Suffix List to break the URL into 3 parts: the scheme and subdomain, the eTLD+1, and all remaining parts (port, path, query, etc.).
28 lines
555 B
C++
28 lines
555 B
C++
/*
|
|
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Optional.h>
|
|
#include <AK/StringView.h>
|
|
#include <AK/URL.h>
|
|
|
|
namespace WebView {
|
|
|
|
enum class AppendTLD {
|
|
No,
|
|
Yes,
|
|
};
|
|
Optional<URL> sanitize_url(StringView, Optional<StringView> search_engine = {}, AppendTLD = AppendTLD::No);
|
|
|
|
struct URLParts {
|
|
StringView scheme_and_subdomain;
|
|
StringView effective_tld_plus_one;
|
|
StringView remainder;
|
|
};
|
|
Optional<URLParts> break_url_into_parts(StringView url);
|
|
|
|
}
|