diff --git a/src/app/components/event/event.component.html b/src/app/components/event/event.component.html
index 123f0db..3f390d7 100644
--- a/src/app/components/event/event.component.html
+++ b/src/app/components/event/event.component.html
@@ -22,10 +22,10 @@
|
-
+ |
{{event?.createdBy}}
|
-
+ |
|
@@ -33,6 +33,7 @@
Start Date must not be after end date!
Required fields are missing!
Error creating event. Please try again.
+ Invalid URL, please only provide valid ones!
|
diff --git a/src/app/components/event/event.component.ts b/src/app/components/event/event.component.ts
index 9fd14e6..c52ecdc 100644
--- a/src/app/components/event/event.component.ts
+++ b/src/app/components/event/event.component.ts
@@ -16,6 +16,7 @@ export class EventComponent implements OnInit {
newEndDate: string | undefined;
newEndTime: string | undefined;
showDateError: boolean = false;
+ invalidUrlError: boolean = false;
requiredFieldsMissing: boolean = false;
showCreateError: boolean = false;
@Output() deleteEvent = new EventEmitter();
@@ -53,6 +54,11 @@ export class EventComponent implements OnInit {
return;
}
+ if(!this.checkEventValidUrl()) {
+ this.invalidUrlError = true;
+ return;
+ }
+
if(this.event.eventId === undefined) {
this.api.createEvent(this.event).subscribe((res: any) => {
console.log(res);
@@ -148,4 +154,27 @@ export class EventComponent implements OnInit {
});
}
}
+
+ checkEventValidUrl(): boolean {
+ if(this.isNullOrBlank(this.event!.url)) {
+ return true;
+ }
+
+ const urlRegex = /^(https?:\/\/)?((www\.)?([a-z0-9äöü]*\.)+[a-z]{2,10}.*)$/i;
+
+ let validUrl = urlRegex.test(this.event!.url);
+
+ if(validUrl){
+ let match = this.event!.url.match(urlRegex);
+ if(match) {
+ console.log(match);
+ let url = 'https://' + match[2];
+ this.event!.url = url;
+ } else {
+ validUrl = false;
+ }
+ }
+
+ return validUrl;
+ }
}
|