From 04699ff9e117b5c1b237370adadd05cd9404c626 Mon Sep 17 00:00:00 2001 From: Alexey Zimarev Date: Mon, 27 May 2024 15:51:58 +0200 Subject: [PATCH] Ok, it is `dontEscape` so needs to be true. --- src/RestSharp/Request/UriExtensions.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/RestSharp/Request/UriExtensions.cs b/src/RestSharp/Request/UriExtensions.cs index 41485467b..9c3df0eb6 100644 --- a/src/RestSharp/Request/UriExtensions.cs +++ b/src/RestSharp/Request/UriExtensions.cs @@ -36,7 +36,9 @@ public static Uri MergeBaseUrlAndResource(this Uri? baseUrl, string? resource) { #if NET6_0_OR_GREATER ? new Uri(assembled, UriOptions) #else - ? new Uri(assembled, false) +#pragma warning disable CS0618 // Type or member is obsolete + ? new Uri(assembled, true) +#pragma warning restore CS0618 // Type or member is obsolete #endif : throw new ArgumentException("Both BaseUrl and Resource are empty", nameof(resource)); } @@ -53,8 +55,10 @@ public static Uri MergeBaseUrlAndResource(this Uri? baseUrl, string? resource) { return assembled != null ? new Uri(isResourceAbsolute ? assembled : $"{usingBaseUri.AbsoluteUri}{assembled}", UriOptions) : baseUrl; #else - var usingBaseUri = baseUrl.AbsoluteUri.EndsWith("/") || assembled.IsEmpty() ? baseUrl : new Uri($"{baseUrl.AbsoluteUri}/", false); - return assembled != null ? new Uri(usingBaseUri, assembled, false) : baseUrl; +#pragma warning disable CS0618 // Type or member is obsolete + var usingBaseUri = baseUrl.AbsoluteUri.EndsWith("/") || assembled.IsEmpty() ? baseUrl : new Uri($"{baseUrl.AbsoluteUri}/", true); + return assembled != null ? new Uri(usingBaseUri, assembled, true) : baseUrl; +#pragma warning restore CS0618 // Type or member is obsolete #endif } @@ -66,10 +70,10 @@ public static Uri AddQueryString(this Uri uri, string? query) { var result = #if NET6_0_OR_GREATER - new Uri($"{absoluteUri}{separator}{query}", new UriCreationOptions { DangerousDisablePathAndQueryCanonicalization = true }); + new Uri($"{absoluteUri}{separator}{query}", UriOptions); #else #pragma warning disable CS0618 // Type or member is obsolete - new Uri($"{absoluteUri}{separator}{query}", false); + new Uri($"{absoluteUri}{separator}{query}", true); #pragma warning restore CS0618 // Type or member is obsolete #endif return result;