1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 22:48:11 +00:00
serenity/Userland/Libraries/LibWeb/URLEncoder.cpp
Max Wipfli a603e69599 AK+Everywhere: Replace usages of URLParser::urlencode() and urldecode()
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.
2021-06-01 09:28:05 +02:00

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();
}
}