From 42b38c884d43c042077ac2beb2e39d8efe2e5390 Mon Sep 17 00:00:00 2001 From: Pedram Rezaei Date: Sat, 12 Sep 2026 15:27:49 -0700 Subject: [PATCH 1/3] Add dedicated NuGet package documentation --- PACKAGE_README.md | 40 +++++++++++++++++++ .../Cloudtoid.UrlPattern.csproj | 4 +- 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 PACKAGE_README.md diff --git a/PACKAGE_README.md b/PACKAGE_README.md new file mode 100644 index 0000000..7da8547 --- /dev/null +++ b/PACKAGE_README.md @@ -0,0 +1,40 @@ +# Cloudtoid.UrlPattern + +Match URL paths and extract named values with readable patterns. Supports prefix and exact matching, optional sections, wildcards, and regular expressions. Compiled patterns are cached for reuse. + +## Install + +Requires .NET 10 or later. + +```sh +dotnet add package Cloudtoid.UrlPattern +``` + +## Example + +```csharp +using Cloudtoid.UrlPattern; + +var engine = new PatternEngine(); +var match = engine.Match( + pattern: "exact: /category/:category/product/:product", + path: "/category/furniture/product/black-couch"); + +Console.WriteLine(match.Variables["category"]); // furniture +Console.WriteLine(match.Variables["product"]); // black-couch +``` + +Pass the URL path only, starting with `/`; exclude the scheme, host, query string, and fragment. `Match` throws when matching fails; use `TryMatch` to handle a non-match without an exception. + +## Pattern syntax + +- `:name` captures a named value. +- `*` matches characters within a path segment, excluding `/`. +- Parentheses mark optional sections, such as `/products(/:id)`. +- `exact: ` requires the entire path to match. +- `prefix: ` matches a prefix and is the default mode. +- `regex: ` enables regular expressions with named captures. + +For dependency injection, call `services.AddUrlPattern()` and inject `IPatternEngine`. + +[Full syntax and examples](https://github.com/cloudtoid/url-pattern) · [Report an issue](https://github.com/cloudtoid/url-pattern/issues) · [MIT license](https://github.com/cloudtoid/url-pattern/blob/master/LICENSE) diff --git a/src/Cloudtoid.UrlPattern/Cloudtoid.UrlPattern.csproj b/src/Cloudtoid.UrlPattern/Cloudtoid.UrlPattern.csproj index d45f8ec..16507aa 100644 --- a/src/Cloudtoid.UrlPattern/Cloudtoid.UrlPattern.csproj +++ b/src/Cloudtoid.UrlPattern/Cloudtoid.UrlPattern.csproj @@ -6,7 +6,7 @@ - README.md + PACKAGE_README.md Cloudtoid.UrlPattern Cloudtoid.UrlPattern pedram@rezaei.us @@ -23,7 +23,7 @@ - + From bb8c13c8c4ea36616e378e07fec18136044fcee2 Mon Sep 17 00:00:00 2001 From: Pedram Rezaei Date: Sat, 12 Sep 2026 15:34:09 -0700 Subject: [PATCH 2/3] Update Cloudtoid.CodeAnalysis to 1.0.28 --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 7fdde89..3ec41bc 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -17,7 +17,7 @@ 1.0.121 - 1.0.24 + 1.0.28 10.0.12 From 91004c16f8c63cd2582cedb03c4c73c03bf82020 Mon Sep 17 00:00:00 2001 From: Pedram Rezaei Date: Sat, 12 Sep 2026 15:41:30 -0700 Subject: [PATCH 3/3] Update Cloudtoid.Framework to 1.0.123 --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 3ec41bc..cc5f87b 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -16,7 +16,7 @@ - 1.0.121 + 1.0.123 1.0.28 10.0.12