Philiprehberger.UrlBuilder 0.1.3

dotnet add package Philiprehberger.UrlBuilder --version 0.1.3
                    
NuGet\Install-Package Philiprehberger.UrlBuilder -Version 0.1.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Philiprehberger.UrlBuilder" Version="0.1.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Philiprehberger.UrlBuilder" Version="0.1.3" />
                    
Directory.Packages.props
<PackageReference Include="Philiprehberger.UrlBuilder" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Philiprehberger.UrlBuilder --version 0.1.3
                    
#r "nuget: Philiprehberger.UrlBuilder, 0.1.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Philiprehberger.UrlBuilder@0.1.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Philiprehberger.UrlBuilder&version=0.1.3
                    
Install as a Cake Addin
#tool nuget:?package=Philiprehberger.UrlBuilder&version=0.1.3
                    
Install as a Cake Tool

Philiprehberger.UrlBuilder

CI NuGet Last updated

Fluent, immutable URL construction with path segments, query parameters, and proper encoding.

Installation

dotnet add package Philiprehberger.UrlBuilder

Usage

Building URLs with Path and Query Parameters

using Philiprehberger.UrlBuilder;

string url = Url.Base("https://api.example.com")
    .Path("v2", "users")
    .Query("page", 1)
    .Query("sort", "name")
    .Build();
// "https://api.example.com/v2/users?page=1&sort=name"

Multi-Value Query Parameters

using Philiprehberger.UrlBuilder;

string url = Url.Base("https://example.com/search")
    .Query("tag", new[] { "csharp", "dotnet" })
    .RemoveQuery("obsolete")
    .Build();
// "https://example.com/search?tag=csharp&tag=dotnet"

Fragments, Scheme, Host, and Port

using Philiprehberger.UrlBuilder;

Uri uri = Url.Base("https://example.com")
    .Path("docs")
    .Fragment("getting-started")
    .Port(8443)
    .ToUri();
// https://example.com:8443/docs#getting-started

API

Url

Method Description
Base(string baseUrl) Create a new UrlBuilder from a base URL.

UrlBuilder

Method Description
Path(params string[] segments) Append path segments.
Query(string key, object value) Add a query parameter.
Query(string key, IEnumerable values) Add multiple values for a query parameter.
RemoveQuery(string key) Remove a query parameter by key.
Fragment(string fragment) Set the URL fragment.
Scheme(string scheme) Set the URL scheme.
Host(string host) Set the URL host.
Port(int port) Set the URL port.
Build() Build the URL as a string.
ToUri() Build the URL as a Uri instance.

All methods return a new UrlBuilder instance, preserving immutability.

Development

dotnet build src/Philiprehberger.UrlBuilder.csproj --configuration Release

Support

If you find this project useful:

Star the repo

🐛 Report issues

💡 Suggest features

❤️ Sponsor development

🌐 All Open Source Projects

💻 GitHub Profile

🔗 LinkedIn Profile

License

MIT

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.3 120 4/1/2026
0.1.2 111 3/25/2026
0.1.1 108 3/25/2026
0.1.0 105 3/23/2026