mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 12:20:00 +01:00
This is the return value of a URLPattern after `exec` is called on it.
It conveys information about the named (or unammed) regex groups
matched for each component of the URL. For example,
```
let p = new URLPattern({ hostname: "{:subdomain.}*example.com" });
const result = pattern.exec({ hostname: "foo.bar.example.com" });
console.log(result.hostname.groups.subdomain);
```
Will log 'foo.bar'.
46 lines
1.0 KiB
C++
46 lines
1.0 KiB
C++
/*
|
|
* Copyright (c) 2025, Shannon Booth <shannon@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/HashMap.h>
|
|
#include <AK/String.h>
|
|
#include <AK/Variant.h>
|
|
#include <AK/Vector.h>
|
|
#include <LibURL/Pattern/Init.h>
|
|
|
|
namespace URL::Pattern {
|
|
|
|
// https://urlpattern.spec.whatwg.org/#typedefdef-urlpatterninput
|
|
using Input = Variant<String, Init>;
|
|
|
|
// https://urlpattern.spec.whatwg.org/#dictdef-urlpatternoptions
|
|
struct Options {
|
|
bool ignore_case { false };
|
|
};
|
|
|
|
// https://urlpattern.spec.whatwg.org/#dictdef-urlpatterncomponentresult
|
|
struct ComponentResult {
|
|
String input;
|
|
OrderedHashMap<String, Variant<String, Empty>> groups;
|
|
};
|
|
|
|
// https://urlpattern.spec.whatwg.org/#dictdef-urlpatternresult
|
|
struct Result {
|
|
Vector<Input> inputs;
|
|
|
|
ComponentResult protocol;
|
|
ComponentResult username;
|
|
ComponentResult password;
|
|
ComponentResult hostname;
|
|
ComponentResult port;
|
|
ComponentResult pathname;
|
|
ComponentResult search;
|
|
ComponentResult hash;
|
|
};
|
|
|
|
}
|