From 2a89800606346b3832ca76fde6bd8d9c849d0e6f Mon Sep 17 00:00:00 2001 From: somerandomname Date: Mon, 8 Sep 2025 20:36:11 +0530 Subject: [PATCH] BuildUserAgent method support OS name parsing with and without spaces --- generate/templates/Configuration.handlebars | 2 +- src/Vault/Client/Configuration.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/generate/templates/Configuration.handlebars b/generate/templates/Configuration.handlebars index 963a8f33..afd6ba27 100644 --- a/generate/templates/Configuration.handlebars +++ b/generate/templates/Configuration.handlebars @@ -351,7 +351,7 @@ namespace {{packageName}}.Client public string BuildUserAgent() { StringBuilder sb = new StringBuilder("vault-client-dotnet/"); - string OSName = RuntimeInformation.OSDescription.Substring(0, RuntimeInformation.OSDescription.IndexOf(" ")); + string OSName = RuntimeInformation.OSDescription.Contains(" ") ? RuntimeInformation.OSDescription.Substring(0, RuntimeInformation.OSDescription.IndexOf(" ")) : RuntimeInformation.OSDescription; sb.AppendFormat("{0} ({1} {2}; .Net {3})", Version, OSName, RuntimeInformation.ProcessArchitecture, System.Environment.Version); return sb.ToString(); } diff --git a/src/Vault/Client/Configuration.cs b/src/Vault/Client/Configuration.cs index 9c79c5df..fb387b37 100644 --- a/src/Vault/Client/Configuration.cs +++ b/src/Vault/Client/Configuration.cs @@ -338,7 +338,7 @@ public string GetApiKeyWithPrefix(string apiKeyIdentifier) public string BuildUserAgent() { StringBuilder sb = new StringBuilder("vault-client-dotnet/"); - string OSName = RuntimeInformation.OSDescription.Substring(0, RuntimeInformation.OSDescription.IndexOf(" ")); + string OSName = RuntimeInformation.OSDescription.Contains(" ") ? RuntimeInformation.OSDescription.Substring(0, RuntimeInformation.OSDescription.IndexOf(" ")) : RuntimeInformation.OSDescription; sb.AppendFormat("{0} ({1} {2}; .Net {3})", Version, OSName, RuntimeInformation.ProcessArchitecture, System.Environment.Version); return sb.ToString(); }