mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-12 02:59:45 +00:00
LibURL: Add a representation of a URL Pattern 'result'
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'.
This commit is contained in:
parent
d873dc0744
commit
dc2c62825b
Notes:
github-actions[bot]
2025-02-10 17:06:41 +00:00
Author: https://github.com/shannonbooth
Commit: dc2c62825b
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3237
Reviewed-by: https://github.com/tcl3 ✅
1 changed files with 23 additions and 0 deletions
|
@ -6,7 +6,10 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/HashMap.h>
|
||||||
|
#include <AK/String.h>
|
||||||
#include <AK/Variant.h>
|
#include <AK/Variant.h>
|
||||||
|
#include <AK/Vector.h>
|
||||||
#include <LibURL/Pattern/Init.h>
|
#include <LibURL/Pattern/Init.h>
|
||||||
|
|
||||||
namespace URL::Pattern {
|
namespace URL::Pattern {
|
||||||
|
@ -19,4 +22,24 @@ struct Options {
|
||||||
bool ignore_case { false };
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue