{"id":21327874,"url":"https://github.com/siddiqsoft/splituri","last_synced_at":"2026-04-23T06:12:52.435Z","repository":{"id":47773626,"uuid":"392412426","full_name":"SiddiqSoft/SplitUri","owner":"SiddiqSoft","description":"Split Uri for modern C++","archived":false,"fork":false,"pushed_at":"2025-01-09T09:55:28.000Z","size":113,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-04-14T23:41:55.417Z","etag":null,"topics":["cpp","cpp20","http","http-utils","nlohmann-json","parser","uri-parser","utility","windows"],"latest_commit_sha":null,"homepage":"https://siddiqsoft.github.io/SplitUri/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SiddiqSoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-08-03T18:13:29.000Z","updated_at":"2025-01-09T09:47:17.000Z","dependencies_parsed_at":"2023-01-30T02:01:23.697Z","dependency_job_id":null,"html_url":"https://github.com/SiddiqSoft/SplitUri","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SiddiqSoft%2FSplitUri","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SiddiqSoft%2FSplitUri/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SiddiqSoft%2FSplitUri/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SiddiqSoft%2FSplitUri/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SiddiqSoft","download_url":"https://codeload.github.com/SiddiqSoft/SplitUri/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248981258,"owners_count":21193143,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","cpp20","http","http-utils","nlohmann-json","parser","uri-parser","utility","windows"],"created_at":"2024-11-21T21:20:12.166Z","updated_at":"2026-04-23T06:12:52.428Z","avatar_url":"https://github.com/SiddiqSoft.png","language":"C++","readme":"SplitUri : Parse Uri Utility\n-------------------------------------------\n\u003c!-- badges --\u003e\n[![Build Status](https://dev.azure.com/siddiqsoft/siddiqsoft/_apis/build/status/SiddiqSoft.SplitUri?branchName=main)](https://dev.azure.com/siddiqsoft/siddiqsoft/_build/latest?definitionId=14\u0026branchName=main)\n[![Build Status](https://dev.azure.com/siddiqsoft/siddiqsoft/_apis/build/status/SiddiqSoft.SplitUri?branchName=develop)](https://dev.azure.com/siddiqsoft/siddiqsoft/_build/latest?definitionId=14\u0026branchName=develop)\n![](https://img.shields.io/nuget/v/SiddiqSoft.SplitUri)\n![](https://img.shields.io/github/v/tag/SiddiqSoft/SplitUri)\n![](https://img.shields.io/azure-devops/tests/siddiqsoft/siddiqsoft/14)\n\u003c!--![](https://img.shields.io/azure-devops/coverage/siddiqsoft/siddiqsoft/14)--\u003e\n\u003c!-- end badges --\u003e\n\n# Objective\n\nParse the Uri for HTTP resources with support for `std::format` and `nlohmann.json` serializers.\n\nConforms to the [WHATWG URL Standard](https://url.spec.whatwg.org/) specification.\n\nWhile there are many, many libraries available, the goal of this implementation is to make *usage* easy.\n\n## Features\n- **WHATWG URL Standard conformance** including:\n  - All special schemes: `ftp` (port 21), `file`, `http` (port 80), `https` (port 443), `ws` (port 80), `wss` (port 443)\n  - Case-insensitive scheme parsing (e.g., `HTTPS://` is recognized as `https`)\n  - Host lowercasing for special schemes per the domain-to-ASCII algorithm\n  - Separate `username` and `password` credential fields\n  - Leading/trailing C0 control and space character stripping\n  - ASCII tab and newline removal from input\n  - Backslash (`\\`) normalization to forward slash (`/`) for special schemes\n  - IPv6 address support in bracket notation `[::1]`\n  - Path dot-segment resolution (`.` and `..` segments)\n  - Port validation (must be 0-65535, out-of-range results in validation error)\n  - `defaultPortForScheme()` and `isSpecialScheme()` utility functions\n- Literals support so you can use `auto u= \"https://www.siddiqsoft.com/\"_Uri;`\n- Formatters for `std::format` as well as serializers for `nlohmann.json` library.\n- Support for `std::string` and `std::wstring`\n- Cross-platform header-only with googletest framework for tests. _Build and tests are for Visual Studio 2019 under x64._\n\nPlease refer to the [documentation](https://siddiqsoft.github.io/SplitUri/).\n\n## WHATWG URL Standard\n\nThis library conforms to the [WHATWG URL Standard](https://url.spec.whatwg.org/) with the following key behaviors:\n\n### Special Schemes (§4.2)\n| Scheme | Default Port |\n|--------|-------------|\n| `ftp`  | 21          |\n| `file` | _(none)_    |\n| `http` | 80          |\n| `https`| 443         |\n| `ws`   | 80          |\n| `wss`  | 443         |\n\n### URL Components\n```\nscheme://username:password@host:port/path?query#fragment\n```\n\n### Key Conformance Points\n- **Scheme**: Parsed case-insensitively and stored as the canonical lowercase form\n- **Host**: Lowercased for special schemes (domain-to-ASCII)\n- **Port**: Validated as 16-bit unsigned integer (0-65535); out-of-range ports result in port being set to 0\n- **Credentials**: `username` and `password` are parsed as separate fields from `user:pass@host`\n- **Input sanitization**: Leading/trailing C0 control characters and spaces are stripped; ASCII tabs and newlines are removed\n- **Path resolution**: Single-dot (`.`) and double-dot (`..`) path segments are resolved\n- **Backslash normalization**: `\\` is treated as `/` in path parsing for special schemes\n\n## Usage\n\n\u003e Breaking change with `v1.9.0` the literals namespace has been changed to `siddiqsoft::splituri_literals`.\n\n\u003e 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.\n\n### New Scheme Types\n```cpp\n// WebSocket support\nauto ws = siddiqsoft::SplitUri(\"ws://example.com:9090/chat\");\n// ws.scheme == UriScheme::WebSocket\n// ws.authority.port == 9090\n\n// WebSocket Secure support\nauto wss = siddiqsoft::SplitUri(\"wss://example.com/chat\");\n// wss.scheme == UriScheme::WebSocketSecure\n// wss.authority.port == 443\n\n// FTP support\nauto ftp = siddiqsoft::SplitUri(\"ftp://files.example.com/pub/readme.txt\");\n// ftp.scheme == UriScheme::Ftp\n// ftp.authority.port == 21\n```\n\n### Password Parsing\n```cpp\nauto uri = siddiqsoft::SplitUri(\"https://user:secret@example.com/\");\n// uri.authority.userInfo == \"user\"\n// uri.authority.password == \"secret\"\n// uri.authority.host == \"example.com\"\n```\n\n### Utility Functions\n```cpp\n// Check if a scheme is special per WHATWG\nbool special = siddiqsoft::isSpecialScheme(siddiqsoft::UriScheme::WebHttps); // true\n\n// Get default port for a scheme\nuint16_t port = siddiqsoft::defaultPortForScheme(siddiqsoft::UriScheme::WebHttps); // 443\n```\n\n\u003cp align=\"right\"\u003e\n\u0026copy; 2021 Siddiq Software LLC. All rights reserved.\n\u003c/p\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiddiqsoft%2Fsplituri","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsiddiqsoft%2Fsplituri","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiddiqsoft%2Fsplituri/lists"}