SiddiqSoft.SplitUri 3.0.3

dotnet add package SiddiqSoft.SplitUri --version 3.0.3
                    
NuGet\Install-Package SiddiqSoft.SplitUri -Version 3.0.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="SiddiqSoft.SplitUri" Version="3.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SiddiqSoft.SplitUri" Version="3.0.3" />
                    
Directory.Packages.props
<PackageReference Include="SiddiqSoft.SplitUri" />
                    
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 SiddiqSoft.SplitUri --version 3.0.3
                    
#r "nuget: SiddiqSoft.SplitUri, 3.0.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 SiddiqSoft.SplitUri@3.0.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=SiddiqSoft.SplitUri&version=3.0.3
                    
Install as a Cake Addin
#tool nuget:?package=SiddiqSoft.SplitUri&version=3.0.3
                    
Install as a Cake Tool

SplitUri : Parse Uri Utility

Build Status Build Status alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

Objective

Parse the Uri for HTTP resources with support for std::format and nlohmann.json serializers.

Conforms to the WHATWG URL Standard specification.

While there are many, many libraries available, the goal of this implementation is to make usage easy.

Features

  • WHATWG URL Standard conformance including:
    • All special schemes: ftp (port 21), file, http (port 80), https (port 443), ws (port 80), wss (port 443)
    • Case-insensitive scheme parsing (e.g., HTTPS:// is recognized as https)
    • Host lowercasing for special schemes per the domain-to-ASCII algorithm
    • Separate username and password credential fields
    • Leading/trailing C0 control and space character stripping
    • ASCII tab and newline removal from input
    • Backslash (\) normalization to forward slash (/) for special schemes
    • IPv6 address support in bracket notation [::1]
    • Path dot-segment resolution (. and .. segments)
    • Port validation (must be 0-65535, out-of-range results in validation error)
    • defaultPortForScheme() and isSpecialScheme() utility functions
  • Literals support so you can use auto u= "https://www.siddiqsoft.com/"_Uri;
  • Formatters for std::format as well as serializers for nlohmann.json library.
  • Support for std::string and std::wstring
  • Cross-platform header-only with googletest framework for tests. Build and tests are for Visual Studio 2019 under x64.

Please refer to the documentation.

WHATWG URL Standard

This library conforms to the WHATWG URL Standard with the following key behaviors:

Special Schemes (§4.2)

Scheme Default Port
ftp 21
file (none)
http 80
https 443
ws 80
wss 443

URL Components

scheme://username:password@host:port/path?query#fragment

Key Conformance Points

  • Scheme: Parsed case-insensitively and stored as the canonical lowercase form
  • Host: Lowercased for special schemes (domain-to-ASCII)
  • Port: Validated as 16-bit unsigned integer (0-65535); out-of-range ports result in port being set to 0
  • Credentials: username and password are parsed as separate fields from user:pass@host
  • Input sanitization: Leading/trailing C0 control characters and spaces are stripped; ASCII tabs and newlines are removed
  • Path resolution: Single-dot (.) and double-dot (..) path segments are resolved
  • Backslash normalization: \ is treated as / in path parsing for special schemes

Usage

Breaking change with v1.9.0 the literals namespace has been changed to siddiqsoft::splituri_literals.

Breaking change with WHATWG conformance: AuthorityHttp now has a separate password field. The userInfo field contains only the username. Host names are lowercased for special schemes.

New Scheme Types

// WebSocket support
auto ws = siddiqsoft::SplitUri("ws://example.com:9090/chat");
// ws.scheme == UriScheme::WebSocket
// ws.authority.port == 9090

// WebSocket Secure support
auto wss = siddiqsoft::SplitUri("wss://example.com/chat");
// wss.scheme == UriScheme::WebSocketSecure
// wss.authority.port == 443

// FTP support
auto ftp = siddiqsoft::SplitUri("ftp://files.example.com/pub/readme.txt");
// ftp.scheme == UriScheme::Ftp
// ftp.authority.port == 21

Password Parsing

auto uri = siddiqsoft::SplitUri("https://user:secret@example.com/");
// uri.authority.userInfo == "user"
// uri.authority.password == "secret"
// uri.authority.host == "example.com"

Utility Functions

// Check if a scheme is special per WHATWG
bool special = siddiqsoft::isSpecialScheme(siddiqsoft::UriScheme::WebHttps); // true

// Get default port for a scheme
uint16_t port = siddiqsoft::defaultPortForScheme(siddiqsoft::UriScheme::WebHttps); // 443

<p align="right"> © 2021 Siddiq Software LLC. All rights reserved. </p>

Product Compatible and additional computed target framework versions.
native native is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on SiddiqSoft.SplitUri:

Package Downloads
SiddiqSoft.restcl

Focussed REST Client for modern C++

SiddiqSoft.CosmosClient

Azure Cosmos REST-API Client for Modern C++

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.3 159 4/28/2026
2.1.1 501 1/9/2025
2.1.0 909 12/7/2024
2.0.0 703 10/26/2024
1.9.0-rc0002 411 10/26/2024
1.8.5 480 10/26/2024
1.8.4 958 6/1/2022
1.8.3 1,057 11/20/2021
1.8.2 843 9/8/2021
1.8.1 735 9/8/2021
1.8.0 22,160 9/8/2021
1.7.0 9,682 8/29/2021
1.6.5 729 8/28/2021
1.6.4 936 8/18/2021
1.6.3 744 8/18/2021
1.6.2 765 8/16/2021
1.6.1 944 8/16/2021
1.5.1 746 8/13/2021
1.5.0 1,622 8/13/2021
1.4.1 721 8/9/2021
Loading failed