Soenneker.Utils.String 4.0.3155

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Utils.String --version 4.0.3155
                    
NuGet\Install-Package Soenneker.Utils.String -Version 4.0.3155
                    
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="Soenneker.Utils.String" Version="4.0.3155" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Utils.String" Version="4.0.3155" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Utils.String" />
                    
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 Soenneker.Utils.String --version 4.0.3155
                    
#r "nuget: Soenneker.Utils.String, 4.0.3155"
                    
#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 Soenneker.Utils.String@4.0.3155
                    
#: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=Soenneker.Utils.String&version=4.0.3155
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Utils.String&version=4.0.3155
                    
Install as a Cake Tool

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 alternate text is missing from this package README image

alternate text is missing from this package README image Soenneker.Utils.String

String helpers for query strings, lightweight model binding, URL extraction, templates, compound identifiers, and Base64-encoded JSON.

Installation

dotnet add package Soenneker.Utils.String

Most helpers are static and can be called directly:

using Soenneker.Utils.String;

string id = StringUtil.ToCombinedId("customer", "42");
string? returnUrl = StringUtil.GetQueryParameter(
    "https://example.test/callback?returnUrl=%2Faccount%3Ftab%3Dsecurity",
    "returnUrl");

ToCombinedId removes null and empty parts and joins the rest with :. It does not escape delimiters, so do not use it where parts containing : must remain distinguishable.

Query strings

GetQueryParameter returns the first matching value from any string containing a ?. Names and values use form-style decoding, where percent escapes are decoded and + becomes a space. A key without = has an empty value, matching is case-sensitive, and URL fragments are excluded.

GetQueryParameters accepts an absolute URI and returns an ordinal, case-sensitive dictionary. The first occurrence of a duplicate decoded key wins. It returns null when the input is not an absolute URI or has no query parameters.

Dictionary<string, string>? values = StringUtil.GetQueryParameters(
    "https://example.test/search?q=red+shoes&page=2");

// values["q"] == "red shoes"

Binding query strings

Register IStringUtil when you need the reflection-based binder or email-domain extraction through dependency injection:

using Soenneker.Utils.String.Abstract;
using Soenneker.Utils.String.Registrars;

services.AddStringUtilAsSingleton();

public sealed class SearchService(IStringUtil strings)
{
    public SearchRequest Parse(string query) => strings.ParseQueryString<SearchRequest>(query);
}

ParseQueryString<T> creates T, matches query keys to public writable properties without regard to case, and converts values with Convert.ChangeType. Unknown keys are ignored. It is intended for simple scalar properties; failed conversions throw, and nullable, collection, or complex properties require a different binding strategy.

ParseQueryStringUsingJson<T> is the tolerant static alternative. It builds a string-valued dictionary and deserializes it through Soenneker.Utils.Json; conversion failures return null and are written to the optional logger.

Other helpers

  • GetDomainFromEmail returns the text after the last @ when both sides are non-empty. It does not validate an email address.
  • ExtractUrls finds URL-shaped substrings. Treat the results as candidates, not validated or trusted destinations.
  • BuildStringFromTemplate replaces brace-delimited placeholders sequentially with non-null values. Placeholder names are informational; unmatched placeholders remain in the result, and braces are not escaped.
  • ConvertBase64JsonToObject<T> decodes standard Base64 containing UTF-8 JSON. Invalid Base64 or JSON throws. It does not accept the Base64Url alphabet.

ConvertBase64JsonToObject<T> clears the portion of its pooled decode buffer before returning it, but decoded objects and input strings remain managed memory. Do not treat it as a complete secret-erasure mechanism.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Soenneker.Utils.String:

Package Downloads
Soenneker.Validators.Email.Disposable.Online

A validation module checking for disposable email addresses via online sources

Soenneker.Validators.Email.Disposable

A validation module checking if a given email's domain is disposable/temporary, updated daily (if available)

Soenneker.Validators.Email.Mx

A validation module checking for the existence of domain MX records

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.3160 0 8/31/2026
4.0.3158 0 8/31/2026
4.0.3156 0 8/31/2026
4.0.3155 0 8/30/2026
4.0.3154 24 8/30/2026
4.0.3152 63 8/30/2026
4.0.3150 35 8/30/2026
4.0.3148 73 8/30/2026
4.0.3146 42 8/30/2026
4.0.3144 42 8/30/2026
4.0.3142 53 8/30/2026
4.0.3141 108 8/29/2026
4.0.3139 37 8/29/2026
4.0.3138 98 8/29/2026
4.0.3137 116 8/27/2026
4.0.3136 83 8/26/2026
4.0.3135 91 8/26/2026
4.0.3134 108 8/26/2026
4.0.3133 69 8/26/2026
4.0.3132 55 8/26/2026
Loading failed

Improve string utility documentation and query handling