mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 03:25:13 +00:00
LibURL/Pattern: Add representation of a URL Pattern 'options' struct
These control how a pattern string is generated, which can vary for different components and is also impacted by the 'ignoreCase' option that can be provided in the URLPattern constructor.
This commit is contained in:
parent
88bea4a717
commit
f3679184cb
Notes:
github-actions[bot]
2025-04-06 12:27:58 +00:00
Author: https://github.com/shannonbooth Commit: https://github.com/LadybirdBrowser/ladybird/commit/f3679184cb5 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3847 Reviewed-by: https://github.com/trflynn89
3 changed files with 72 additions and 0 deletions
|
@ -10,6 +10,7 @@ set(SOURCES
|
|||
Pattern/Canonicalization.cpp
|
||||
Pattern/ConstructorStringParser.cpp
|
||||
Pattern/Init.cpp
|
||||
Pattern/Options.cpp
|
||||
Pattern/Part.cpp
|
||||
Pattern/Pattern.cpp
|
||||
Pattern/String.cpp
|
||||
|
|
41
Libraries/LibURL/Pattern/Options.cpp
Normal file
41
Libraries/LibURL/Pattern/Options.cpp
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Shannon Booth <shannon@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibURL/Pattern/Options.h>
|
||||
|
||||
namespace URL::Pattern {
|
||||
|
||||
// https://urlpattern.spec.whatwg.org/#default-options
|
||||
Options Options::default_()
|
||||
{
|
||||
// The default options is an options struct with delimiter code point set to the empty string and prefix code point set to the empty string.
|
||||
return {
|
||||
.delimiter_code_point = {},
|
||||
.prefix_code_point = {},
|
||||
};
|
||||
}
|
||||
|
||||
// https://urlpattern.spec.whatwg.org/#hostname-options
|
||||
Options Options::hostname()
|
||||
{
|
||||
// The hostname options is an options struct with delimiter code point set "." and prefix code point set to the empty string.
|
||||
return {
|
||||
.delimiter_code_point = '.',
|
||||
.prefix_code_point = {},
|
||||
};
|
||||
}
|
||||
|
||||
// https://urlpattern.spec.whatwg.org/#pathname-options
|
||||
Options Options::pathname()
|
||||
{
|
||||
// The pathname options is an options struct with delimiter code point set "/" and prefix code point set to "/".
|
||||
return {
|
||||
.delimiter_code_point = '/',
|
||||
.prefix_code_point = '/',
|
||||
};
|
||||
}
|
||||
|
||||
}
|
30
Libraries/LibURL/Pattern/Options.h
Normal file
30
Libraries/LibURL/Pattern/Options.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Shannon Booth <shannon@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Optional.h>
|
||||
|
||||
namespace URL::Pattern {
|
||||
|
||||
// https://urlpattern.spec.whatwg.org/#options
|
||||
struct Options {
|
||||
// https://urlpattern.spec.whatwg.org/#options-delimiter-code-point
|
||||
Optional<char> delimiter_code_point;
|
||||
|
||||
// https://urlpattern.spec.whatwg.org/#options-prefix-code-point
|
||||
Optional<char> prefix_code_point;
|
||||
|
||||
// https://urlpattern.spec.whatwg.org/#options-ignore-case
|
||||
bool ignore_case { false };
|
||||
|
||||
static Options default_();
|
||||
static Options hostname();
|
||||
static Options pathname();
|
||||
};
|
||||
;
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue