22 lines
591 B
C#
22 lines
591 B
C#
|
|
using System;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
|
||
|
|
namespace RudderSdk.Core;
|
||
|
|
|
||
|
|
internal static class Url
|
||
|
|
{
|
||
|
|
public static string Encode(string? value) => Uri.EscapeDataString(value ?? string.Empty);
|
||
|
|
|
||
|
|
public static string Query(params (string Key, string? Value)[] values)
|
||
|
|
{
|
||
|
|
var parts = new List<string>();
|
||
|
|
foreach (var item in values)
|
||
|
|
{
|
||
|
|
if (!string.IsNullOrEmpty(item.Value))
|
||
|
|
parts.Add(Encode(item.Key) + "=" + Encode(item.Value));
|
||
|
|
}
|
||
|
|
|
||
|
|
return parts.Count == 0 ? string.Empty : "?" + string.Join("&", parts);
|
||
|
|
}
|
||
|
|
}
|