2021-09-13 01:00:47 +03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2021-09-13 21:50:05 +03:00
|
|
|
#include <AK/URL.h>
|
|
|
|
|
#include <AK/Vector.h>
|
2022-09-25 17:03:42 +01:00
|
|
|
#include <LibWeb/WebIDL/ExceptionOr.h>
|
2021-09-13 01:00:47 +03:00
|
|
|
|
|
|
|
|
namespace Web::URL {
|
|
|
|
|
|
2021-09-13 21:50:05 +03:00
|
|
|
struct QueryParam {
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString name;
|
|
|
|
|
DeprecatedString value;
|
2021-09-13 21:50:05 +03:00
|
|
|
};
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString url_encode(Vector<QueryParam> const&, AK::URL::PercentEncodeSet);
|
2021-11-11 00:55:02 +01:00
|
|
|
Vector<QueryParam> url_decode(StringView);
|
2021-09-13 21:50:05 +03:00
|
|
|
|
2022-09-04 14:04:42 +02:00
|
|
|
class URLSearchParams : public Bindings::PlatformObject {
|
|
|
|
|
WEB_PLATFORM_OBJECT(URLSearchParams, Bindings::PlatformObject);
|
2021-09-13 01:00:47 +03:00
|
|
|
|
2022-09-04 14:04:42 +02:00
|
|
|
public:
|
LibWeb: Remove unecessary dependence on Window from assorted classes
These classes only needed Window to get at its realm. Pass a realm
directly to construct Crypto, Encoding, HRT, IntersectionObserver,
NavigationTiming, Page, RequestIdleCallback, Selection, Streams, URL,
and XML classes.
2022-09-25 18:11:21 -06:00
|
|
|
static JS::NonnullGCPtr<URLSearchParams> create(JS::Realm&, Vector<QueryParam> list);
|
2022-12-04 18:02:33 +00:00
|
|
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<URLSearchParams>> construct_impl(JS::Realm&, Variant<Vector<Vector<DeprecatedString>>, OrderedHashMap<DeprecatedString, DeprecatedString>, DeprecatedString> const& init);
|
2021-09-13 01:00:47 +03:00
|
|
|
|
2022-09-04 14:04:42 +02:00
|
|
|
virtual ~URLSearchParams() override;
|
2021-09-13 01:00:47 +03:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
void append(DeprecatedString const& name, DeprecatedString const& value);
|
|
|
|
|
void delete_(DeprecatedString const& name);
|
|
|
|
|
DeprecatedString get(DeprecatedString const& name);
|
|
|
|
|
Vector<DeprecatedString> get_all(DeprecatedString const& name);
|
|
|
|
|
bool has(DeprecatedString const& name);
|
|
|
|
|
void set(DeprecatedString const& name, DeprecatedString const& value);
|
2021-09-13 01:00:47 +03:00
|
|
|
|
|
|
|
|
void sort();
|
|
|
|
|
|
2022-12-06 01:12:49 +00:00
|
|
|
DeprecatedString to_deprecated_string() const;
|
2021-09-13 01:00:47 +03:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
using ForEachCallback = Function<JS::ThrowCompletionOr<void>(DeprecatedString const&, DeprecatedString const&)>;
|
2021-10-31 10:03:29 -04:00
|
|
|
JS::ThrowCompletionOr<void> for_each(ForEachCallback);
|
2021-09-28 02:11:55 +03:00
|
|
|
|
2021-09-13 01:00:47 +03:00
|
|
|
private:
|
2021-09-14 00:10:22 +03:00
|
|
|
friend class URL;
|
2021-09-28 02:11:55 +03:00
|
|
|
friend class URLSearchParamsIterator;
|
2021-09-14 00:10:22 +03:00
|
|
|
|
LibWeb: Remove unecessary dependence on Window from assorted classes
These classes only needed Window to get at its realm. Pass a realm
directly to construct Crypto, Encoding, HRT, IntersectionObserver,
NavigationTiming, Page, RequestIdleCallback, Selection, Streams, URL,
and XML classes.
2022-09-25 18:11:21 -06:00
|
|
|
URLSearchParams(JS::Realm&, Vector<QueryParam> list);
|
2022-09-04 14:04:42 +02:00
|
|
|
|
2023-01-28 12:33:35 -05:00
|
|
|
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
2022-09-04 14:04:42 +02:00
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
2021-09-13 01:00:47 +03:00
|
|
|
|
|
|
|
|
void update();
|
|
|
|
|
|
|
|
|
|
Vector<QueryParam> m_list;
|
2022-09-04 14:04:42 +02:00
|
|
|
JS::GCPtr<URL> m_url;
|
2021-09-13 01:00:47 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|