prevent Blazor keyword in project name. closes #9182

pull/9185/head
Alper Ebicoglu 4 years ago
parent 1a6f09473d
commit d21fe36074

@ -17,6 +17,11 @@ namespace Volo.Abp.Cli.Utils
"LPT2"
};
private static readonly string[] IllegalKeywords = new[]
{
"Blazor"
};
private static bool HasParentDirectoryString(string projectName)
{
return projectName.Contains("..");
@ -40,6 +45,19 @@ namespace Volo.Abp.Cli.Utils
return false;
}
private static bool HasIllegalKeywords(string projectName)
{
foreach (var illegalKeyword in IllegalKeywords)
{
if (projectName.Contains(illegalKeyword))
{
return true;
}
}
return false;
}
public static bool IsValid(string projectName)
{
if (projectName == null)
@ -62,6 +80,11 @@ namespace Volo.Abp.Cli.Utils
return false;
}
if (HasIllegalKeywords(projectName))
{
return false;
}
return true;
}
}

@ -45,5 +45,23 @@ namespace Volo.Abp.Cli
var args = new CommandLineArgs("new", "Test..Test");
await _newCommand.ExecuteAsync(args).ShouldThrowAsync<CliUsageException>();
}
[Fact]
public async Task Has_Illegel_Keyword_Test()
{
var illegalKeywords = new[]
{
"Acme.Blazor",
"MyBlazor",
};
foreach (var illegalKeyword in illegalKeywords)
{
var args = new CommandLineArgs("new", illegalKeyword);
await _newCommand.ExecuteAsync(args).ShouldThrowAsync<CliUsageException>();
}
}
}
}

Loading…
Cancel
Save