using System.Text; namespace xApi.Extensions { public static class HttpExtensions { /// /// Apply Query String to Specified Url ... /// /// /// /// public static string ApplyQueryString( this string url, IDictionary? queries = null ) { // var result = url; if (queries is null || string.IsNullOrWhiteSpace(result)) { return result; } // // Handling ... bool isMarkupAdded = false; var sb = new StringBuilder(); sb.Append(result); foreach (var param in queries) { // if (string.IsNullOrWhiteSpace(param.Value)) { continue; } // sb.Append(isMarkupAdded ? '&' : '?'); sb.Append(param.Key); sb.Append('='); sb.Append(param.Value); // isMarkupAdded = true; } // result = sb.ToString(); // return result; } /// /// Normalize a URL Segment ... /// /// /// public static string NormalizeUrlSegent( this string segment ) { // if (!string.IsNullOrWhiteSpace(segment) && segment.StartsWith("/") ) { segment = segment[1..]; } // return segment; } } }