feat(router): enforce convention of CamelCase names in route aliases

Closes #4083
This commit is contained in:
Brian Ford
2015-09-14 16:01:09 -07:00
parent cb4a9a3c04
commit 5298eb0709
3 changed files with 34 additions and 0 deletions

View File

@ -44,6 +44,12 @@ export class RouteRecognizer {
config(config: RouteDefinition): boolean {
var handler;
if (isPresent(config.as) && config.as[0].toUpperCase() != config.as[0]) {
var suggestedAlias = config.as[0].toUpperCase() + config.as.substring(1);
throw new BaseException(
`Route '${config.path}' with alias '${config.as}' does not begin with an uppercase letter. Route aliases should be CamelCase like '${suggestedAlias}'.`);
}
if (config instanceof AuxRoute) {
handler = new SyncRouteHandler(config.component, config.data);
let path = config.path.startsWith('/') ? config.path.substring(1) : config.path;