mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02: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:
Notes:
github-actions[bot]
2025-04-06 12:27:50 +00:00
Author: https://github.com/shannonbooth Commit: https://github.com/LadybirdBrowser/ladybird/commit/e3ef6d3aeea Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3847 Reviewed-by: https://github.com/trflynn89
@@ -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&);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user