Fix event URL validation and check if hostname is correct before showing
it Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
4727c8861e
commit
f82c3b7492
@ -38,7 +38,7 @@
|
||||
</div>
|
||||
|
||||
<b-field :label="$t('Website / URL')">
|
||||
<b-input icon="link" v-model="event.onlineAddress" placeholder="URL" />
|
||||
<b-input icon="link" type="url" v-model="event.onlineAddress" placeholder="URL" />
|
||||
</b-field>
|
||||
|
||||
<!--<b-field :label="$t('Category')">
|
||||
|
@ -118,7 +118,7 @@ import {ParticipantRole} from "@/types/event.model";
|
||||
</div>
|
||||
</b-modal>
|
||||
</div>
|
||||
<span class="online-address" v-if="event.onlineAddress">
|
||||
<span class="online-address" v-if="event.onlineAddress && urlToHostname(event.onlineAddress)">
|
||||
<b-icon icon="link"></b-icon>
|
||||
<a :href="event.onlineAddress">{{ urlToHostname(event.onlineAddress) }}</a>
|
||||
</span>
|
||||
@ -548,8 +548,12 @@ export default class Event extends EventMixin {
|
||||
return this.event.options.maximumAttendeeCapacity - this.event.participantStats.participants;
|
||||
}
|
||||
|
||||
urlToHostname(url: string): string {
|
||||
urlToHostname(url: string): string|null {
|
||||
try {
|
||||
return (new URL(url)).hostname;
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user