Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit 3f15fd8

Browse files
oodamienghillert
authored andcommitted
Add Apps: fix URI Regex
Update tests Resolves #898
1 parent 394af23 commit 3f15fd8

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

ui/src/app/apps/apps-add/apps-add.validator.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ describe('AppsAddValidator', () => {
1313
[
1414
' ',
1515
'bb',
16-
' http://foo.ly/foo',
1716
'b b'
1817
].forEach((mock) => {
1918
const uri: FormControl = new FormControl(mock);
@@ -23,7 +22,9 @@ describe('AppsAddValidator', () => {
2322
it('valid', () => {
2423
[
2524
'http://foo.ly/foo',
26-
'http://foo.bar:bar.foo-foo:bar-bar'
25+
'http://foo.bar:bar.foo-foo:bar-bar',
26+
'http://foo.bar/foo.bar&a=a',
27+
'http://foo.bar/foo.bar&b=b?a=a'
2728
].forEach((mock) => {
2829
const uri: FormControl = new FormControl(mock);
2930
expect(AppsAddValidator.uri(uri)).toBeNull();

ui/src/app/apps/apps-add/apps-add.validator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {FormControl, FormGroup} from '@angular/forms';
1+
import { FormControl, FormGroup } from '@angular/forms';
22

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

1616
/**
1717
* Validate the uri conditions

ui/src/app/apps/apps-add/uri/apps-bulk-import-uri.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { AppsService } from '../../apps.service';
88
import { BusyService } from '../../../shared/services/busy.service';
99
import { NotificationService } from '../../../shared/services/notification.service';
1010
import { AppsAddValidator } from '../apps-add.validator';
11+
import { AppError } from '../../../shared/model/error.model';
1112

1213
/**
1314
* Applications Bulk Import
@@ -83,6 +84,8 @@ export class AppsBulkImportUriComponent implements OnDestroy {
8384
.subscribe(data => {
8485
this.notificationService.success('Apps Imported.');
8586
this.router.navigate(['apps']);
87+
}, (error) => {
88+
this.notificationService.error(AppError.is(error) ? error.getMessage() : error);
8689
});
8790

8891
this.busyService.addSubscription(busy);

0 commit comments

Comments
 (0)