-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LibURL+LibWeb: Add initial set of stubs for URLPatternInit #3224
Merged
AtkinsSJ
merged 2 commits into
LadybirdBrowser:master
from
shannonbooth:urlpattern-start-upstreaming
Jan 27, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (c) 2025, Shannon Booth <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <AK/Optional.h> | ||
#include <AK/String.h> | ||
|
||
namespace URL::Pattern { | ||
|
||
// https://urlpattern.spec.whatwg.org/#dictdef-urlpatterninit | ||
struct Init { | ||
Optional<String> protocol; | ||
Optional<String> username; | ||
Optional<String> password; | ||
Optional<String> hostname; | ||
Optional<String> port; | ||
Optional<String> pathname; | ||
Optional<String> search; | ||
Optional<String> hash; | ||
Optional<String> base_url; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright (c) 2025, Shannon Booth <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <AK/Variant.h> | ||
#include <LibURL/Pattern/Init.h> | ||
|
||
namespace URL::Pattern { | ||
|
||
// https://urlpattern.spec.whatwg.org/#typedefdef-urlpatterninput | ||
using Input = Variant<String, Init>; | ||
|
||
// https://urlpattern.spec.whatwg.org/#dictdef-urlpatternoptions | ||
struct Options { | ||
bool ignore_case { false }; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (c) 2025, Shannon Booth <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#include <LibWeb/Bindings/Intrinsics.h> | ||
#include <LibWeb/Bindings/URLPatternPrototype.h> | ||
#include <LibWeb/URLPattern/URLPattern.h> | ||
#include <LibWeb/WebIDL/ExceptionOr.h> | ||
|
||
namespace Web::URLPattern { | ||
|
||
GC_DEFINE_ALLOCATOR(URLPattern); | ||
|
||
URLPattern::URLPattern(JS::Realm& realm) | ||
: PlatformObject(realm) | ||
{ | ||
} | ||
|
||
URLPattern::~URLPattern() = default; | ||
|
||
void URLPattern::initialize(JS::Realm& realm) | ||
{ | ||
Base::initialize(realm); | ||
WEB_SET_PROTOTYPE_FOR_INTERFACE(URLPattern); | ||
} | ||
|
||
WebIDL::ExceptionOr<GC::Ref<URLPattern>> URLPattern::construct_impl(JS::Realm& realm, URLPatternInput const&, String const&, URLPatternOptions const&) | ||
{ | ||
return realm.create<URLPattern>(realm); | ||
} | ||
|
||
WebIDL::ExceptionOr<GC::Ref<URLPattern>> URLPattern::construct_impl(JS::Realm& realm, URLPatternInput const&, URLPatternOptions const&) | ||
{ | ||
return realm.create<URLPattern>(realm); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (c) 2025, Shannon Booth <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <AK/String.h> | ||
#include <LibURL/Pattern/Init.h> | ||
#include <LibURL/Pattern/Pattern.h> | ||
#include <LibWeb/Bindings/PlatformObject.h> | ||
|
||
namespace Web::URLPattern { | ||
|
||
using URLPatternInit = URL::Pattern::Init; | ||
using URLPatternInput = URL::Pattern::Input; | ||
using URLPatternOptions = URL::Pattern::Options; | ||
|
||
// https://urlpattern.spec.whatwg.org/#urlpattern | ||
class URLPattern : public Bindings::PlatformObject { | ||
WEB_PLATFORM_OBJECT(URLPattern, Bindings::PlatformObject); | ||
GC_DECLARE_ALLOCATOR(URLPattern); | ||
|
||
public: | ||
static WebIDL::ExceptionOr<GC::Ref<URLPattern>> construct_impl(JS::Realm&, URLPatternInput const&, String const& base_url, URLPatternOptions const& = {}); | ||
static WebIDL::ExceptionOr<GC::Ref<URLPattern>> construct_impl(JS::Realm&, URLPatternInput const&, URLPatternOptions const& = {}); | ||
|
||
virtual ~URLPattern() override; | ||
|
||
protected: | ||
virtual void initialize(JS::Realm&) override; | ||
|
||
explicit URLPattern(JS::Realm&); | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
typedef (USVString or URLPatternInit) URLPatternInput; | ||
|
||
// https://urlpattern.spec.whatwg.org/#urlpattern | ||
[Exposed=(Window,Worker)] | ||
interface URLPattern { | ||
constructor(URLPatternInput input, USVString baseURL, optional URLPatternOptions options = {}); | ||
constructor(optional URLPatternInput input = {}, optional URLPatternOptions options = {}); | ||
|
||
[FIXME] boolean test(optional URLPatternInput input = {}, optional USVString baseURL); | ||
|
||
[FIXME] 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; | ||
|
||
[FIXME] readonly attribute boolean hasRegExpGroups; | ||
}; | ||
|
||
// https://urlpattern.spec.whatwg.org/#dictdef-urlpatterninit | ||
dictionary URLPatternInit { | ||
USVString protocol; | ||
USVString username; | ||
USVString password; | ||
USVString hostname; | ||
USVString port; | ||
USVString pathname; | ||
USVString search; | ||
USVString hash; | ||
USVString baseURL; | ||
}; | ||
|
||
// https://urlpattern.spec.whatwg.org/#dictdef-urlpatternoptions | ||
dictionary URLPatternOptions { | ||
boolean ignoreCase = false; | ||
}; | ||
|
||
// https://urlpattern.spec.whatwg.org/#dictdef-urlpatternresult | ||
dictionary URLPatternResult { | ||
sequence<URLPatternInput> inputs; | ||
|
||
URLPatternComponentResult protocol; | ||
URLPatternComponentResult username; | ||
URLPatternComponentResult password; | ||
URLPatternComponentResult hostname; | ||
URLPatternComponentResult port; | ||
URLPatternComponentResult pathname; | ||
URLPatternComponentResult search; | ||
URLPatternComponentResult hash; | ||
}; | ||
|
||
// https://urlpattern.spec.whatwg.org/#dictdef-urlpatterncomponentresult | ||
dictionary URLPatternComponentResult { | ||
USVString input; | ||
record<USVString, (USVString or undefined)> groups; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -394,6 +394,7 @@ TypeError | |
UIEvent | ||
URIError | ||
URL | ||
URLPattern | ||
URLSearchParams | ||
Uint16Array | ||
Uint32Array | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only thing about putting it in LibURL is it will add an additional dependency on it to LibRegex, but I think that's fine