mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-04 15:19:42 +00:00
LibURL/Pattern: Implement ability to generate a pattern string
Compiling a URLPattern component will generate a 'parts list' which is used for generating the regular expression that is used for matching against URLs. This parts list is also used to generate (through this function) a pattern string. The pattern string of a URL component is what is exposed on the USVString getters of the URLPattern class itself. As an example, the following: ``` let pattern = new URLPattern({ "pathname": "/foo/(.*)*" }); console.log(pattern.pathname); ``` Will log the pattern string of: '/foo/**'.
This commit is contained in:
parent
f3679184cb
commit
e3ef6d3aee
Notes:
github-actions[bot]
2025-04-06 12:27:50 +00:00
Author: https://github.com/shannonbooth
Commit: e3ef6d3aee
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3847
Reviewed-by: https://github.com/trflynn89
2 changed files with 269 additions and 0 deletions
|
@ -7,9 +7,17 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <LibURL/Pattern/Options.h>
|
||||
#include <LibURL/Pattern/Part.h>
|
||||
|
||||
namespace URL::Pattern {
|
||||
|
||||
// https://urlpattern.spec.whatwg.org/#full-wildcard-regexp-value
|
||||
static inline constexpr auto full_wildcard_regexp_value = ".*"sv;
|
||||
|
||||
String escape_a_pattern_string(String const&);
|
||||
String escape_a_regexp_string(String const&);
|
||||
String generate_a_segment_wildcard_regexp(Options const&);
|
||||
String generate_a_pattern_string(ReadonlySpan<Part>, Options const&);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue