-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: remove dependency towards Microsoft.AspNetCore.WebUtilities
- Loading branch information
Showing
8 changed files
with
50 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text.Encodings.Web; | ||
|
||
namespace Vonage.Common; | ||
|
||
/// <summary> | ||
/// Exposes helpers methods when working with queries. | ||
/// </summary> | ||
public static class UriHelpers | ||
{ | ||
/// <summary> | ||
/// Builds a URI from a base URI and query parameters. | ||
/// </summary> | ||
/// <param name="baseUri">The base URI.</param> | ||
/// <param name="parameters">The query parameters.</param> | ||
/// <returns>The URI.</returns> | ||
public static string BuildUri(string baseUri, Dictionary<string, string> parameters) | ||
{ | ||
var queryParams = string.Join("&", parameters | ||
.Select(pair => $"{UrlEncoder.Default.Encode(pair.Key)}={UrlEncoder.Default.Encode(pair.Value)}")); | ||
return queryParams.Length > 0 ? $"{baseUri}?{queryParams}" : baseUri; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters