Skip to content

Commit

Permalink
Merge pull request #2383 from cloudfoundry-incubator/route-sanity-che…
Browse files Browse the repository at this point in the history
…cking

Validate host/path pattern in Create Route form
  • Loading branch information
nwmac authored Jun 19, 2018
2 parents 9270744 + 63e887b commit 962fcdb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@
<div>
<mat-form-field>
<input matInput formControlName="host" placeholder="Host" required>
<mat-error *ngIf="addHTTPRoute.controls['host'].errors?.pattern">Invalid Hostname</mat-error>
</mat-form-field>
</div>
<div>
<mat-form-field>
<input matInput formControlName="path" placeholder="Path">
<mat-error *ngIf="addHTTPRoute.controls['path'].errors?.pattern">Invalid Path</mat-error>
<span matPrefix>/&nbsp;</span>
</mat-form-field>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ import { FetchAllDomains } from '../../../../store/actions/domains.actions';
import { PaginationMonitorFactory } from '../../../../shared/monitors/pagination-monitor.factory';
import { getPaginationObservables } from '../../../../store/reducers/pagination-reducer/pagination-reducer.helper';


const hostPattern = '^([\\w\\-\\.]*)$';
const pathPattern = `^([\\w\\-\\/\\!\\#\\[\\]\\@\\&\\$\\'\\(\\)\\*\\+\\;\\=\\,]*)$`;
@Component({
selector: 'app-add-routes',
templateUrl: './add-routes.component.html',
Expand Down Expand Up @@ -87,8 +88,8 @@ export class AddRoutesComponent implements OnInit, OnDestroy {
});

this.addHTTPRoute = new FormGroup({
host: new FormControl('', [<any>Validators.required]),
path: new FormControl('')
host: new FormControl('', [<any>Validators.required, Validators.pattern(hostPattern)]),
path: new FormControl('', [Validators.pattern(pathPattern)])
});
this.addRouteMode = this.addRouteModes[0];

Expand Down

0 comments on commit 962fcdb

Please sign in to comment.