From c6551a63dfe4a937767cb21b527c8f2045dfe126 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Sun, 8 Sep 2024 16:45:16 +0200 Subject: [PATCH] Improved the rules for provider names --- .../Dialogs/ProviderDialog.razor.cs | 34 ++----------------- .../wwwroot/changelog/v0.9.7.md | 3 +- 2 files changed, 5 insertions(+), 32 deletions(-) diff --git a/app/MindWork AI Studio/Dialogs/ProviderDialog.razor.cs b/app/MindWork AI Studio/Dialogs/ProviderDialog.razor.cs index 02d29d22..09c32b93 100644 --- a/app/MindWork AI Studio/Dialogs/ProviderDialog.razor.cs +++ b/app/MindWork AI Studio/Dialogs/ProviderDialog.razor.cs @@ -1,5 +1,3 @@ -using System.Text.RegularExpressions; - using AIStudio.Provider; using AIStudio.Settings; @@ -245,40 +243,14 @@ public partial class ProviderDialog : ComponentBase return null; } - - [GeneratedRegex(@"^[a-zA-Z0-9\-_. ]+$")] - private static partial Regex InstanceNameRegex(); - - private static readonly string[] RESERVED_NAMES = ["CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9"]; - + private string? ValidatingInstanceName(string instanceName) { if (string.IsNullOrWhiteSpace(instanceName)) return "Please enter an instance name."; - if (instanceName.StartsWith(' ') || instanceName.StartsWith('.')) - return "The instance name must not start with a space or a dot."; - - if (instanceName.EndsWith(' ') || instanceName.EndsWith('.')) - return "The instance name must not end with a space or a dot."; - - if (instanceName.StartsWith('-') || instanceName.StartsWith('_')) - return "The instance name must not start with a hyphen or an underscore."; - - if (instanceName.Length > 255) - return "The instance name must not exceed 255 characters."; - - if (!InstanceNameRegex().IsMatch(instanceName)) - return "The instance name must only contain letters, numbers, spaces, hyphens, underscores, and dots."; - - if (instanceName.Contains(" ")) - return "The instance name must not contain consecutive spaces."; - - if (RESERVED_NAMES.Contains(instanceName.ToUpperInvariant())) - return "This name is reserved and cannot be used."; - - if (instanceName.Any(c => Path.GetInvalidFileNameChars().Contains(c))) - return "The instance name contains invalid characters."; + if (instanceName.Length > 40) + return "The instance name must not exceed 40 characters."; // The instance name must be unique: var lowerInstanceName = instanceName.ToLowerInvariant(); diff --git a/app/MindWork AI Studio/wwwroot/changelog/v0.9.7.md b/app/MindWork AI Studio/wwwroot/changelog/v0.9.7.md index 355b4133..718f1ccc 100644 --- a/app/MindWork AI Studio/wwwroot/changelog/v0.9.7.md +++ b/app/MindWork AI Studio/wwwroot/changelog/v0.9.7.md @@ -1,3 +1,4 @@ # v0.9.7, build 182 (2024-09-09 xx:xx UTC) - Added an introductory description to the provider settings. -- Improved hyphenation for continuous text so that the rules of the respective language are taken into account where possible. \ No newline at end of file +- Improved hyphenation for continuous text so that the rules of the respective language are taken into account where possible. +- Improved the rules for provider names: unnecessary restrictions from earlier versions have been removed. You can now use emojis in your provider names when you like. \ No newline at end of file