mirror of https://github.com/abpframework/abp
Reference: https://stackoverflow.com/questions/773557/which-characters-are-allowed-in-a-vs-project-name
Reference: dcf5adbd4b/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/ValueForms/DefaultSafeNamespaceValueFormModel.cs (L35)
pull/2190/head
parent
f321f8aea0
commit
3bb802da6b
@ -0,0 +1,21 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Volo.Abp.Cli.Utils
|
||||
{
|
||||
public static class NamespaceHelper
|
||||
{
|
||||
public static string NormalizeNamespace([CanBeNull] string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
value = Regex.Replace(value, @"(^\s+|\s+$)", "");
|
||||
value = Regex.Replace(value, @"(((?<=\.)|^)((?=\d)|\.)|[^\w\.])|(\.$)", "_");
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue