mirror of
https://github.com/RGBCube/serenity
synced 2025-05-30 22:48:11 +00:00

This replaces all occurrences of those functions with the newly implemented functions URL::percent_encode() and URL::percent_decode(). The old functions will be removed in a further commit.
26 lines
592 B
C++
26 lines
592 B
C++
/*
|
|
* Copyright (c) 2020, the SerenityOS developers.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <AK/StringBuilder.h>
|
|
#include <AK/URL.h>
|
|
#include <LibWeb/URLEncoder.h>
|
|
|
|
namespace Web {
|
|
|
|
String urlencode(const Vector<URLQueryParam>& pairs)
|
|
{
|
|
StringBuilder builder;
|
|
for (size_t i = 0; i < pairs.size(); ++i) {
|
|
builder.append(URL::percent_encode(pairs[i].name));
|
|
builder.append('=');
|
|
builder.append(URL::percent_encode(pairs[i].value));
|
|
if (i != pairs.size() - 1)
|
|
builder.append('&');
|
|
}
|
|
return builder.to_string();
|
|
}
|
|
|
|
}
|