Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion addon/ng2/blueprints/route/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ module.exports = {

normalizeEntityName: function (entityName) {
var parsedPath = dynamicPathParser(this.project, entityName);


// If a specified route starts with `+` remove it as it'd break convention.
if (parsedPath.name[0] === '+') {
var index = entityName.lastIndexOf(parsedPath.name);
entityName = entityName.substr(0, index) + entityName.substr(index + 1);
Copy link
Copy Markdown
Contributor

@hansl hansl Apr 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused as to what this does. Could you give an example?

Also, commented code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removes the + can't do a replace in case there's a + earlier in the path

Copy link
Copy Markdown
Contributor

@hansl hansl Apr 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could that work?

entityName = path.dirname(entityName) + path.sep + path.basename(entityName).substr(1);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

possibly, but I find it best to work with the raw value there (entityName) in case the purpose and logic of the dynamic path parser changes

}

this.dynamicPath = parsedPath;

//leave the entity name intact for component generation
Expand Down
6 changes: 6 additions & 0 deletions tests/acceptance/generate-route.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,10 @@ describe('Acceptance: ng generate route', function () {
fileExpectations(false, true);
});
});

it('ng generate route +my-route', function () {
return ng(['generate', 'route', '+my-route']).then(() => {
fileExpectations(true, true);
});
});
});