Skip to content

Commit

Permalink
fix(@angular-devkit/core): classify string util should concat strin…
Browse files Browse the repository at this point in the history
…g without using a `.`

`.` is not a valid character in ES6 class names.

Prior to this change `foo.module` before used to be incorrectly classified to `Foo.Module` instead of `FooModule`.

Closes #13824

(cherry picked from commit e63375e)
  • Loading branch information
alan-agius4 authored and clydin committed Jul 21, 2022
1 parent c65e994 commit 44c1808
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/angular_devkit/core/src/utils/strings.ts
Expand Up @@ -74,13 +74,14 @@ export function camelize(str: string): string {
/**
Returns the UpperCamelCase form of a string.
@example
```javascript
'innerHTML'.classify(); // 'InnerHTML'
'action_name'.classify(); // 'ActionName'
'css-class-name'.classify(); // 'CssClassName'
'my favorite items'.classify(); // 'MyFavoriteItems'
'app.component'.classify(); // 'AppComponent'
```
@method classify
@param {String} str the string to classify
@return {String} the classified string
Expand All @@ -89,7 +90,7 @@ export function classify(str: string): string {
return str
.split('.')
.map((part) => capitalize(camelize(part)))
.join('.');
.join('');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/schematics/angular/class/index_spec.ts
Expand Up @@ -83,7 +83,7 @@ describe('Class Schematic', () => {
const tree = await schematicRunner.runSchematicAsync('class', options, appTree).toPromise();
const classPath = '/projects/bar/src/app/foo.model.ts';
const content = tree.readContent(classPath);
expect(content).toMatch(/export class Foo/);
expect(content).toMatch(/export class FooModel/);
});

it('should respect the path option', async () => {
Expand Down

0 comments on commit 44c1808

Please sign in to comment.