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

Commit 760764a

Browse files
Broccohansl
authored andcommitted
fix(@schematics/angular): Disallow paths in project names
1 parent 62ebcd3 commit 760764a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/schematics/angular/utility/validation.ts

+5-1
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
@@ -43,7 +44,10 @@ export function validateProjectName(projectName: string) {
4344
`;
4445
throw new SchematicsException(msg);
4546
} else if (unsupportedProjectNames.indexOf(projectName) !== -1) {
46-
throw new SchematicsException(`Project name "${projectName}" is not a supported name.`);
47+
throw new SchematicsException(
48+
`Project name ${JSON.stringify(projectName)} is not a supported name.`);
49+
} else if (!packageNameRegex.test(projectName)) {
50+
throw new SchematicsException(`Project name ${JSON.stringify(projectName)} is invalid.`);
4751
}
4852
}
4953

0 commit comments

Comments
 (0)