/* * Copyright (c) 2021, Idan Horowitz * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include namespace Web::URL { struct QueryParam { String name; String value; }; String url_encode(Vector const&, AK::URL::PercentEncodeSet); Vector url_decode(StringView); class URLSearchParams : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(URLSearchParams, Bindings::PlatformObject); public: static JS::NonnullGCPtr create(JS::Realm&, Vector list); static WebIDL::ExceptionOr> construct_impl(JS::Realm&, Variant>, OrderedHashMap, String> const& init); virtual ~URLSearchParams() override; void append(String const& name, String const& value); void delete_(String const& name); String get(String const& name); Vector get_all(String const& name); bool has(String const& name); void set(String const& name, String const& value); void sort(); String to_string() const; using ForEachCallback = Function(String const&, String const&)>; JS::ThrowCompletionOr for_each(ForEachCallback); private: friend class URL; friend class URLSearchParamsIterator; URLSearchParams(JS::Realm&, Vector list); virtual void visit_edges(Cell::Visitor&) override; void update(); Vector m_list; JS::GCPtr m_url; }; }