Skip to content

Commit

Permalink
Ok, it is dontEscape so needs to be true.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyzimarev committed May 27, 2024
1 parent af7d572 commit 04699ff
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/RestSharp/Request/UriExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand All @@ -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
}

Expand All @@ -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;
Expand Down

0 comments on commit 04699ff

Please sign in to comment.