AK: Add optional parameter for excluding chars to urlencode()
This commit is contained in:
parent
1320b9351e
commit
50e3b122c7
Notes:
sideshowbarker
2024-07-18 22:41:45 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/50e3b122c77 Pull-request: https://github.com/SerenityOS/serenity/pull/5206
2 changed files with 4 additions and 4 deletions
|
@ -90,11 +90,11 @@ static inline bool in_userinfo_set(u32 c)
|
|||
return in_path_set(c) || c == '/' || c == ':' || c == ';' || c == '=' || c == '@' || (c >= '[' && c <= '^') || c == '|';
|
||||
}
|
||||
|
||||
String urlencode(const StringView& input)
|
||||
String urlencode(const StringView& input, const StringView& exclude)
|
||||
{
|
||||
StringBuilder builder;
|
||||
for (unsigned char ch : input) {
|
||||
if (in_userinfo_set((u8)ch)) {
|
||||
if (in_userinfo_set((u8)ch) && !exclude.contains(ch)) {
|
||||
builder.append('%');
|
||||
builder.appendff("{:02X}", ch);
|
||||
} else {
|
||||
|
|
|
@ -26,11 +26,11 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/StringView.h>
|
||||
|
||||
namespace AK {
|
||||
|
||||
String urlencode(const StringView&);
|
||||
String urlencode(const StringView&, const StringView& exclude = {});
|
||||
String urldecode(const StringView&);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue