mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +00:00
LibWeb/URLPattern: Implement the URLPattern IDL getters
These simply return the compiled URLPattern pattern strings for each component, and whether any of the components contained any regexp groups.
This commit is contained in:
parent
f3662c6f88
commit
cf7b775709
Notes:
github-actions[bot]
2025-02-18 00:11:33 +00:00
Author: https://github.com/shannonbooth Commit: https://github.com/LadybirdBrowser/ladybird/commit/cf7b775709e Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3547
3 changed files with 92 additions and 9 deletions
|
@ -43,4 +43,71 @@ Optional<URLPatternResult> URLPattern::exec(URLPatternInput const&, Optional<Str
|
|||
return {};
|
||||
}
|
||||
|
||||
// https://urlpattern.spec.whatwg.org/#dom-urlpattern-protocol
|
||||
String const& URLPattern::protocol() const
|
||||
{
|
||||
// 1. Return this's associated URL pattern's protocol component's pattern string.
|
||||
return m_url_pattern.protocol_component().pattern_string;
|
||||
}
|
||||
|
||||
// https://urlpattern.spec.whatwg.org/#dom-urlpattern-username
|
||||
String const& URLPattern::username() const
|
||||
{
|
||||
// 1. Return this's associated URL pattern's username component's pattern string.
|
||||
return m_url_pattern.username_component().pattern_string;
|
||||
}
|
||||
|
||||
// https://urlpattern.spec.whatwg.org/#dom-urlpattern-password
|
||||
String const& URLPattern::password() const
|
||||
{
|
||||
// 1. Return this's associated URL pattern's password component's pattern string.
|
||||
return m_url_pattern.password_component().pattern_string;
|
||||
}
|
||||
|
||||
// https://urlpattern.spec.whatwg.org/#dom-urlpattern-hostname
|
||||
String const& URLPattern::hostname() const
|
||||
{
|
||||
// 1. Return this's associated URL pattern's hostname component's pattern string.
|
||||
return m_url_pattern.hostname_component().pattern_string;
|
||||
}
|
||||
|
||||
// https://urlpattern.spec.whatwg.org/#dom-urlpattern-port
|
||||
String const& URLPattern::port() const
|
||||
{
|
||||
// 1. Return this's associated URL pattern's port component's pattern string.
|
||||
return m_url_pattern.port_component().pattern_string;
|
||||
}
|
||||
|
||||
// https://urlpattern.spec.whatwg.org/#dom-urlpattern-pathname
|
||||
String const& URLPattern::pathname() const
|
||||
{
|
||||
// 1. Return this's associated URL pattern's pathname component's pattern string.
|
||||
return m_url_pattern.pathname_component().pattern_string;
|
||||
}
|
||||
|
||||
// https://urlpattern.spec.whatwg.org/#dom-urlpattern-search
|
||||
String const& URLPattern::search() const
|
||||
{
|
||||
// 1. Return this's associated URL pattern's search component's pattern string.
|
||||
return m_url_pattern.search_component().pattern_string;
|
||||
}
|
||||
|
||||
// https://urlpattern.spec.whatwg.org/#dom-urlpattern-hash
|
||||
String const& URLPattern::hash() const
|
||||
{
|
||||
// 1. Return this's associated URL pattern's hash component's pattern string.
|
||||
return m_url_pattern.hash_component().pattern_string;
|
||||
}
|
||||
|
||||
// https://urlpattern.spec.whatwg.org/#dom-urlpattern-hasregexpgroups
|
||||
bool URLPattern::has_reg_exp_groups() const
|
||||
{
|
||||
// 1. If this's associated URL pattern's has regexp groups, then return true.
|
||||
if (m_url_pattern.has_regexp_groups())
|
||||
return true;
|
||||
|
||||
// 2. Return false.
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,12 +29,28 @@ public:
|
|||
|
||||
Optional<URLPatternResult> exec(URLPatternInput const&, Optional<String> const&) const;
|
||||
|
||||
String const& protocol() const;
|
||||
String const& username() const;
|
||||
String const& password() const;
|
||||
String const& hostname() const;
|
||||
String const& port() const;
|
||||
String const& pathname() const;
|
||||
String const& search() const;
|
||||
String const& hash() const;
|
||||
|
||||
bool has_reg_exp_groups() const;
|
||||
|
||||
virtual ~URLPattern() override;
|
||||
|
||||
protected:
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
explicit URLPattern(JS::Realm&);
|
||||
|
||||
private:
|
||||
// https://urlpattern.spec.whatwg.org/#ref-for-url-pattern%E2%91%A0
|
||||
// Each URLPattern has an associated URL pattern, a URL pattern.
|
||||
URL::Pattern::Pattern m_url_pattern;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -10,16 +10,16 @@ interface URLPattern {
|
|||
|
||||
URLPatternResult? exec(optional URLPatternInput input = {}, optional USVString baseURL);
|
||||
|
||||
[FIXME] readonly attribute USVString protocol;
|
||||
[FIXME] readonly attribute USVString username;
|
||||
[FIXME] readonly attribute USVString password;
|
||||
[FIXME] readonly attribute USVString hostname;
|
||||
[FIXME] readonly attribute USVString port;
|
||||
[FIXME] readonly attribute USVString pathname;
|
||||
[FIXME] readonly attribute USVString search;
|
||||
[FIXME] readonly attribute USVString hash;
|
||||
readonly attribute USVString protocol;
|
||||
readonly attribute USVString username;
|
||||
readonly attribute USVString password;
|
||||
readonly attribute USVString hostname;
|
||||
readonly attribute USVString port;
|
||||
readonly attribute USVString pathname;
|
||||
readonly attribute USVString search;
|
||||
readonly attribute USVString hash;
|
||||
|
||||
[FIXME] readonly attribute boolean hasRegExpGroups;
|
||||
readonly attribute boolean hasRegExpGroups;
|
||||
};
|
||||
|
||||
// https://urlpattern.spec.whatwg.org/#dictdef-urlpatterninit
|
||||
|
|
Loading…
Add table
Reference in a new issue