1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-08 13:37:10 +09:00
ladybird/Libraries/LibURL/Pattern/String.h
Shannon Booth e3ef6d3aee 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/**'.
2025-04-06 08:24:54 -04:00

23 lines
605 B
C++

/*
* Copyright (c) 2025, Shannon Booth <shannon@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#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&);
}