Skip to content

Commit

Permalink
fix prefix generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Kleak committed Nov 9, 2016
1 parent 9060aff commit ae954bf
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions example/silly/main.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions lib/generator/writer/import.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ class Writer {
void _writeRequestHandler() {
sb.writeln(
"Future<bool> requestHandler(HttpRequest request, {String prefix: ''}) async {");
sb.write("prefix += '${routes.first.pathPrefix}';");
if (routes.first.pathPrefix.isNotEmpty) {
sb.write("prefix += '${routes.first.pathPrefix}';");
}
sb.writeln("PathParams pathParams = new PathParams();");
if (routes.any((RouteInfo route) => route.shouldKeepQueryParam)) {
sb.writeln(
Expand All @@ -106,8 +108,11 @@ class Writer {

// if (forGroupRoute) {
groups.forEach((GroupInfo groupeInfo) {
sb.writeln(
"if (await ${groupeInfo.name}.requestHandler(request, prefix: prefix + '${groupeInfo.group.path}')) {");
sb.write("if (await ${groupeInfo.name}.requestHandler(request");
if (groupeInfo.group.path.isNotEmpty) {
sb.write(",prefix: prefix + '${groupeInfo.group.path}'");
}
sb.write(")) {");
sb.writeln("return true;");
sb.writeln("}");
sb.writeln("");
Expand Down
1 change: 0 additions & 1 deletion test/jaguar/group/book.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion test/jaguar/group/main.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ae954bf

Please sign in to comment.