File tree Expand file tree Collapse file tree 3 files changed +19
-0
lines changed
Userland/Libraries/LibWeb/URL Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,20 @@ void URL::visit_edges(Cell::Visitor& visitor)
9696 visitor.visit (m_query.ptr ());
9797}
9898
99+ // https://url.spec.whatwg.org/#dom-url-canparse
100+ bool URL::can_parse (JS::VM&, String const & url, Optional<String> const & base)
101+ {
102+ // 1. Let parsedURL be the result of running the API URL parser on url with base, if given.
103+ auto parsed_url = parse_api_url (url, base);
104+
105+ // 2. If parsedURL is failure, then return false.
106+ if (!parsed_url.has_value ())
107+ return false ;
108+
109+ // 3. Return true.
110+ return true ;
111+ }
112+
99113WebIDL::ExceptionOr<String> URL::href () const
100114{
101115 auto & vm = realm ().vm ();
Original file line number Diff line number Diff line change 11/*
22 * Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
33 * Copyright (c) 2021, the SerenityOS developers.
4+ * Copyright (c) 2023, networkException <networkexception@serenityos.org>
45 *
56 * SPDX-License-Identifier: BSD-2-Clause
67 */
@@ -23,6 +24,8 @@ class URL : public Bindings::PlatformObject {
2324
2425 virtual ~URL () override ;
2526
27+ static bool can_parse (JS::VM&, String const & url, Optional<String> const & base = {});
28+
2629 WebIDL::ExceptionOr<String> href () const ;
2730 WebIDL::ExceptionOr<void > set_href (String const &);
2831
Original file line number Diff line number Diff line change 55interface URL {
66 constructor(USVString url, optional USVString base);
77
8+ static boolean canParse(USVString url, optional USVString base);
9+
810 stringifier attribute USVString href;
911 readonly attribute USVString origin;
1012 attribute USVString protocol;
You can’t perform that action at this time.
0 commit comments