Skip to content

Commit 5cd7592

Browse files
committed
Merge branch 'bugfix/validate_url' into 'develop'
bugfix/validate_url See merge request upm-inesdata/inesdata-connector-interface!45
2 parents 910cd8f + 2fa4ee1 commit 5cd7592

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

src/app/pages/assets/asset-create/asset-create.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140

141141
<mat-form-field class="form-field" color="accent">
142142
<mat-label>Base URL</mat-label>
143-
<input [(ngModel)]="httpDataAddress.baseUrl" [pattern]="urlPattern" matInput required>
143+
<input [(ngModel)]="httpDataAddress.baseUrl" matInput required>
144144
</mat-form-field>
145145

146146
<mat-form-field class="form-field" color="accent">

src/app/pages/assets/asset-create/asset-create.component.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@ export class AssetCreateComponent implements OnInit {
103103
config = CKEDITOR_CONFIG
104104
selectedAssetTypeVocabularies: Vocabulary[]
105105

106-
urlPattern: RegExp = /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z]{2,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)$/;
107-
108106
private fetch$ = new BehaviorSubject(null);
109107

110108
ngOnInit(): void {
@@ -370,8 +368,12 @@ export class AssetCreateComponent implements OnInit {
370368
}
371369

372370
validateUrl(): boolean {
373-
const regex = new RegExp(this.urlPattern);
374-
return regex.test(this.httpDataAddress.baseUrl);
371+
try {
372+
var url = new URL(this.httpDataAddress.baseUrl);
373+
} catch (e) {
374+
return false;
375+
}
376+
return url.protocol === "http:" || url.protocol === "https:";
375377
}
376378

377379

src/styles.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,7 @@ mat-card-actions {
681681

682682
.creation-card .mat-mdc-card-header {
683683
padding: 0px 0px 20px 0px;
684+
display: flex;
684685
}
685686

686687
app-confirmation-dialog .mat-mdc-dialog-title,

0 commit comments

Comments
 (0)