LibURL: Remove C++ URL Parser implementation

Only exposing compatability wrappers and percent_encode_after_encoding.
This commit is contained in:
Shannon Booth 2026-04-05 17:00:12 +02:00 committed by Shannon Booth
parent 57cc7b04ee
commit 331dd40d9c
2 changed files with 21 additions and 1648 deletions

File diff suppressed because it is too large Load diff

View file

@ -14,61 +14,39 @@
namespace URL {
#define ENUMERATE_STATES \
STATE(SchemeStart) \
STATE(Scheme) \
STATE(NoScheme) \
STATE(SpecialRelativeOrAuthority) \
STATE(PathOrAuthority) \
STATE(Relative) \
STATE(RelativeSlash) \
STATE(SpecialAuthoritySlashes) \
STATE(SpecialAuthorityIgnoreSlashes) \
STATE(Authority) \
STATE(Host) \
STATE(Hostname) \
STATE(Port) \
STATE(File) \
STATE(FileSlash) \
STATE(FileHost) \
STATE(PathStart) \
STATE(Path) \
STATE(OpaquePath) \
STATE(Query) \
STATE(Fragment)
class Parser {
public:
enum class State {
#define STATE(state) state,
ENUMERATE_STATES
#undef STATE
SchemeStart,
Scheme,
NoScheme,
SpecialRelativeOrAuthority,
PathOrAuthority,
Relative,
RelativeSlash,
SpecialAuthoritySlashes,
SpecialAuthorityIgnoreSlashes,
Authority,
Host,
Hostname,
Port,
File,
FileSlash,
FileHost,
PathStart,
Path,
OpaquePath,
Query,
Fragment,
};
static char const* state_name(State const& state)
{
switch (state) {
#define STATE(state) \
case State::state: \
return #state;
ENUMERATE_STATES
#undef STATE
}
VERIFY_NOT_REACHED();
}
// https://url.spec.whatwg.org/#concept-basic-url-parser
static Optional<URL> basic_parse(StringView input, Optional<URL const&> base_url = {}, URL* url = nullptr, Optional<State> state_override = {}, Optional<StringView> encoding = {});
// https://url.spec.whatwg.org/#string-percent-encode-after-encoding
static String percent_encode_after_encoding(TextCodec::Encoder&, StringView input, PercentEncodeSet percent_encode_set, bool space_as_plus = false);
// https://url.spec.whatwg.org/#shorten-a-urls-path
static void shorten_urls_path(URL&);
static Optional<Host> parse_host(StringView input, bool is_opaque = false);
};
#undef ENUMERATE_STATES
}