Use Uri.EscapeDataString in a few others places

This commit is contained in:
Tyrrrz 2025-03-18 19:35:24 +02:00
parent 6f877cf543
commit fca6729ef0

View file

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
namespace DiscordChatExporter.Core.Utils;
@ -25,8 +24,8 @@ public class UrlBuilder
if (ignoreUnsetValue && string.IsNullOrWhiteSpace(value))
return this;
var keyEncoded = WebUtility.UrlEncode(key);
var valueEncoded = WebUtility.UrlEncode(value);
var keyEncoded = Uri.EscapeDataString(key);
var valueEncoded = Uri.EscapeDataString(value);
_queryParameters[keyEncoded] = valueEncoded;
return this;
@ -39,9 +38,11 @@ public class UrlBuilder
buffer.Append(_path);
if (_queryParameters.Any())
{
buffer
.Append('?')
.AppendJoin('&', _queryParameters.Select(kvp => $"{kvp.Key}={kvp.Value}"));
}
return buffer.ToString();
}