Skip to content

Commit

Permalink
Add warning next to route path when it contains query parameters
Browse files Browse the repository at this point in the history
Closes #88
  • Loading branch information
Guillaume committed Jan 13, 2019
1 parent 940f8f0 commit 0a8ec50
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,13 @@
<div class="input-group-prepend">
<span class="input-group-text">/</span>
</div>
<input type="text" class="form-control col-6" placeholder="Path (support regexes and params: */:var/a(b)?c/[0-9]{1,5})" ValidPath name="route.endpoint" [(ngModel)]="currentRoute.route.endpoint"
<input type="text" class="form-control col-6" placeholder="Path supports regexes and params: */:var/a(b)?c/[0-9]{1,5}" ValidPath name="route.endpoint" [(ngModel)]="currentRoute.route.endpoint"
(ngModelChange)="environmentUpdated('endpoint')">
<div class="input-group-prepend">
<span *ngIf="currentEnvironment.environment.running && currentRoute.route.method === 'get'" class="input-group-text text-primary" ngbTooltip="Open route in browser" (click)="openRouteInBrowser()"><i class="material-icons">open_in_new</i></span>
</div>
<div class="input-group-prepend">
<span *ngIf="currentRoute.route.duplicates.length" class="input-group-text text-warning" ngbTooltip="Route is duplicated"><i class="material-icons">warning</i></span>
<span *ngIf="routeHasQueryParams()" class="input-group-text text-warning" ngbTooltip="Route cannot be declared with query parameters, please add them when you call the route"><i class="material-icons">warning</i></span>
</div>
</div>
</div>
Expand Down
7 changes: 7 additions & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,13 @@ export class AppComponent implements OnInit {
return mimeTypesWithTemplating.indexOf(this.currentRoute.route.file.mimeType) > -1;
}

/**
* Check if route has query params
*/
public routeHasQueryParams(): boolean {
return this.currentRoute.route.endpoint && this.currentRoute.route.endpoint.match(/\?.*=/ig).length > 0;
}

/**
* Scroll to bottom of an element
*
Expand Down

0 comments on commit 0a8ec50

Please sign in to comment.