Skip to content

Regex expression in 1.0.0-beta-24 disallows multiple dashes in project name #3680

Closed
@ggoodfrd

Description

@ggoodfrd

Please provide us with the following information:

OS?

Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
Windows 7

Versions.

Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:
angular-cli: 1.0.0-beta.24
node: 7.2.1
os: win32 x64

Repro steps.

Was this an app that wasn't created using the CLI? What change did you do on your code? etc.
Issue detected on creation of a default project using ng new

The log given by the failure.

Normally this include a stack trace and some more information.
Project name "cli-beta-24-base" is not valid. New project names must start with a letter, and must contain only alphanumeric characters or dashes.

Mention any other details that might be useful.

After installing any new build of angular-cli I always create a default project in a sandbox folder. I use the new build as a base for diffing changes to previous versions and to the app I'm developing. Using beta.24 the regex expression disallows the naming convention I've been able to use without issue up through beta-22.

The project name I tried to use this time:
cli-beta-24-base

Please see line 40 of https://github.com/angular/angular-cli/blob/master/packages/angular-cli/commands/new.ts

The regex expression there shows:
/^[a-zA-Z][.0-9a-zA-Z](-[a-zA-Z][.0-9a-zA-Z])*$/

This appears to have been introduced as part of this fix:
#3478

From my experimentation, it appears that the dash in the capture group might be misplaced. The beta.24 regex only seems to allow one occurrence of the dash within the entire name. By moving the dash to the later character set listed in appears to correct the situation and allow multiple dashes within the project name.

An expression that appears to work properly:
/^[a-zA-Z][.0-9a-zA-Z]([a-zA-Z][-.0-9a-zA-Z])*$/

That's about it. It's a minor issue but perhaps this could be addressed in an upcoming build. Thanks for all of the great work!


Thanks! We'll be in touch soon.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions