Skip to content

Commit e63375e

Browse files
alan-agius4clydin
authored andcommitted
fix(@angular-devkit/core): classify string util should concat string 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
1 parent 00515e1 commit e63375e

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/angular_devkit/core/src/utils/strings.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,14 @@ export function camelize(str: string): string {
7474
/**
7575
Returns the UpperCamelCase form of a string.
7676
77+
@example
7778
```javascript
7879
'innerHTML'.classify(); // 'InnerHTML'
7980
'action_name'.classify(); // 'ActionName'
8081
'css-class-name'.classify(); // 'CssClassName'
8182
'my favorite items'.classify(); // 'MyFavoriteItems'
83+
'app.component'.classify(); // 'AppComponent'
8284
```
83-
8485
@method classify
8586
@param {String} str the string to classify
8687
@return {String} the classified string
@@ -89,7 +90,7 @@ export function classify(str: string): string {
8990
return str
9091
.split('.')
9192
.map((part) => capitalize(camelize(part)))
92-
.join('.');
93+
.join('');
9394
}
9495

9596
/**

packages/schematics/angular/class/index_spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ describe('Class Schematic', () => {
8383
const tree = await schematicRunner.runSchematicAsync('class', options, appTree).toPromise();
8484
const classPath = '/projects/bar/src/app/foo.model.ts';
8585
const content = tree.readContent(classPath);
86-
expect(content).toMatch(/export class Foo/);
86+
expect(content).toMatch(/export class FooModel/);
8787
});
8888

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

0 commit comments

Comments
 (0)