Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Commit 43000e5

Browse files
committed
fix(@schematics/angular): Disallow paths in project names
1 parent 693ec98 commit 43000e5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

packages/schematics/angular/utility/validation.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export function validateHtmlSelector(selector: string): void {
3030
export function validateProjectName(projectName: string) {
3131
const errorIndex = getRegExpFailPosition(projectName);
3232
const unsupportedProjectNames = ['test', 'ember', 'ember-cli', 'vendor', 'app'];
33+
const packageNameRegex = /^(?:@[a-zA-Z0-9_-]+\/)?[a-zA-Z0-9_-]+$/;
3334
if (errorIndex !== null) {
3435
const firstMessage = tags.oneLine`
3536
Project name "${projectName}" is not valid. New project names must
@@ -44,6 +45,8 @@ export function validateProjectName(projectName: string) {
4445
throw new SchematicsException(msg);
4546
} else if (unsupportedProjectNames.indexOf(projectName) !== -1) {
4647
throw new SchematicsException(`Project name "${projectName}" is not a supported name.`);
48+
} else if (!packageNameRegex.test(projectName)) {
49+
throw new SchematicsException(`Project name (${projectName}) is invalid.`);
4750
}
4851
}
4952

0 commit comments

Comments
 (0)