jaytwo.UrlHelper
0.2.1-beta-20250915085843
dotnet add package jaytwo.UrlHelper --version 0.2.1-beta-20250915085843
NuGet\Install-Package jaytwo.UrlHelper -Version 0.2.1-beta-20250915085843
<PackageReference Include="jaytwo.UrlHelper" Version="0.2.1-beta-20250915085843" />
<PackageVersion Include="jaytwo.UrlHelper" Version="0.2.1-beta-20250915085843" />
<PackageReference Include="jaytwo.UrlHelper" />
paket add jaytwo.UrlHelper --version 0.2.1-beta-20250915085843
#r "nuget: jaytwo.UrlHelper, 0.2.1-beta-20250915085843"
#:package jaytwo.UrlHelper@0.2.1-beta-20250915085843
#addin nuget:?package=jaytwo.UrlHelper&version=0.2.1-beta-20250915085843&prerelease
#tool nuget:?package=jaytwo.UrlHelper&version=0.2.1-beta-20250915085843&prerelease
jaytwo.UrlHelper
<p align="center"> <a href="https://jenkins.jaytwo.com/job/jaytwo.UrlHelper/job/master/" alt="Build Status (master)"> <img src="https://jenkins.jaytwo.com/buildStatus/icon?job=jaytwo.UrlHelper%2Fmaster&subject=build%20(master)" /></a> <a href="https://jenkins.jaytwo.com/job/jaytwo.UrlHelper/job/develop/" alt="Build Status (develop)"> <img src="https://jenkins.jaytwo.com/buildStatus/icon?job=jaytwo.UrlHelper%2Fdevelop&subject=build%20(develop)" /></a> </p>
<p align="center"> <a href="https://www.nuget.org/packages/jaytwo.UrlHelper/" alt="NuGet Package jaytwo.UrlHelper"> <img src="https://img.shields.io/nuget/v/jaytwo.UrlHelper.svg?logo=nuget&label=jaytwo.UrlHelper" /></a> <a href="https://www.nuget.org/packages/jaytwo.UrlHelper/" alt="NuGet Package jaytwo.UrlHelper (beta)"> <img src="https://img.shields.io/nuget/vpre/jaytwo.UrlHelper.svg?logo=nuget&label=jaytwo.UrlHelper" /></a> </p>
Simple URL manipulation. I wanted a way to manipulate a URL as a string without relying on transforming
it to a System.Uri
and back again. This was not a performance or optimization reasons. Rather, I sometimes
deal with imperfect systems and less-than-properly-formatted URL's. So, I wanted something to manipulate the
URL as a string instead of the Uri
as an object.
At some point in my career I remember learning about a quirk in .NET that made Uri.AbsoluteUri
and Uri.ToString()
handle escaping/unescaping/reescaping differently. I'm pretty sure it had to do with escaping slashes in the path.
I'm also pretty sure this is corrected by now and doesn't matter... but what can I say... old habits die hard.
It's easier in my brain to keep the strings as strings and avoid decoding/reencoding from within the guts of
System.Uri
anyway.
Installation
Add the NuGet package
PM> Install-Package jaytwo.UrlHelper
Usage
Sample Real-Life Usage:
var path = Url.Format("/v8/finance/chart/{0}", symbol);
path = Url.SetQueryParameter(path, "includePrePost", "true");
path = Url.SetQueryParameter(path, "interval", "1d");
path = Url.SetQueryParameter(path, "range", "1m");
var _baseUrl = "https://query1.finance.yahoo.com"
var url = Url.Combine(_baseUrl, path);
Query Operations:
Url.SetQueryParameter("http://www.google.com/?foo=bar", "fizz", 0);
// returns "http://www.google.com/?foo=bar&fizz=0"
Url.GetQueryValue("http://www.google.com/?foo=bar", "foo");
// returns "bar"
Url.GetQueryValueAsArray("http://www.google.com/?foo=bar&foo=baz", "foo");
// returns { "bar", "baz" }
Url.RemoveQueryParameter("http://www.google.com/?foo=bar&fizz=buzz", "foo");
// returns "http://www.google.com/?fizz=buzz"
Url.GetQuery("http://www.google.com/?foo=bar");
// returns "?foo=bar"
Url.RemoveQuery("http://www.google.com/a/b?c=d");
// returns "http://www.google.com/a/b"
Path Operations:
Url.AppendPath("http://www.google.com", "foo/bar");
// returns "http://www.google.com/foo/bar"
Url.AppendPath("http://www.google.com/foo", "hello/{0}", new[] { "a b" });
// returns "http://www.google.com/foo/hello/a%20b"
Url.SetPath("http://www.google.com", "foo/bar");
// returns "http://www.google.com/foo/bar"
Url.SetPath("http://www.google.com/foo", "hello/{0}", new[] { "a b" });
// returns "http://www.google.com/hello/a%20b"
Other Operations:
Url.Format("http://www.google.com/{0}", "foo/bar");
// returns "http://www.google.com/foo%2Fbar"
Url.Format("http://www.google.com/foo/{0}", "bar");
// returns "http://www.google.com/foo/bar"
Url.Combine("http://www.google.com/foo/", "bar");
// returns "http://www.google.com/foo/bar"
Url.Combine("http://www.google.com", "foo/bar?fizz=buzz");
// returns "http://www.google.com/foo/bar?fizz=buzz"
Made with ♥ by Jake
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
-
net6.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages (4)
Showing the top 4 NuGet packages that depend on jaytwo.UrlHelper:
Package | Downloads |
---|---|
jaytwo.FluentUri
Package Description |
|
jaytwo.HttpClient
Package Description |
|
jaytwo.FluentHttp
Package Description |
|
jaytwo.Http.Authentication.OAuth10a
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.