Skip to content

Commit

Permalink
Add Apps: fix URI Regex
Browse files Browse the repository at this point in the history
Update tests
Resolves #898
  • Loading branch information
oodamien authored and ghillert committed Sep 13, 2018
1 parent 394af23 commit 3f15fd8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions ui/src/app/apps/apps-add/apps-add.validator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ describe('AppsAddValidator', () => {
[
' ',
'bb',
' http://foo.ly/foo',
'b b'
].forEach((mock) => {
const uri: FormControl = new FormControl(mock);
Expand All @@ -23,7 +22,9 @@ describe('AppsAddValidator', () => {
it('valid', () => {
[
'http://foo.ly/foo',
'http://foo.bar:bar.foo-foo:bar-bar'
'http://foo.bar:bar.foo-foo:bar-bar',
'http://foo.bar/foo.bar&a=a',
'http://foo.bar/foo.bar&b=b?a=a'
].forEach((mock) => {
const uri: FormControl = new FormControl(mock);
expect(AppsAddValidator.uri(uri)).toBeNull();
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/apps/apps-add/apps-add.validator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {FormControl, FormGroup} from '@angular/forms';
import { FormControl, FormGroup } from '@angular/forms';

/**
* Validators for Bulk Import Form
Expand All @@ -11,7 +11,7 @@ export class AppsAddValidator {
/**
* Uri regex
*/
static uriRegex = /^([a-zA-Z0-9-]+:\/\/)([\\w\\.:-]+)?([a-zA-Z0-9-\/.:-]+)*$/;
static uriRegex = /(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;

/**
* Validate the uri conditions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { AppsService } from '../../apps.service';
import { BusyService } from '../../../shared/services/busy.service';
import { NotificationService } from '../../../shared/services/notification.service';
import { AppsAddValidator } from '../apps-add.validator';
import { AppError } from '../../../shared/model/error.model';

/**
* Applications Bulk Import
Expand Down Expand Up @@ -83,6 +84,8 @@ export class AppsBulkImportUriComponent implements OnDestroy {
.subscribe(data => {
this.notificationService.success('Apps Imported.');
this.router.navigate(['apps']);
}, (error) => {
this.notificationService.error(AppError.is(error) ? error.getMessage() : error);
});

this.busyService.addSubscription(busy);
Expand Down

0 comments on commit 3f15fd8

Please sign in to comment.