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>
|
</div>
|
||||||
|
|
||||||
<b-field :label="$t('Website / URL')">
|
<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>
|
||||||
|
|
||||||
<!--<b-field :label="$t('Category')">
|
<!--<b-field :label="$t('Category')">
|
||||||
|
@ -118,7 +118,7 @@ import {ParticipantRole} from "@/types/event.model";
|
|||||||
</div>
|
</div>
|
||||||
</b-modal>
|
</b-modal>
|
||||||
</div>
|
</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>
|
<b-icon icon="link"></b-icon>
|
||||||
<a :href="event.onlineAddress">{{ urlToHostname(event.onlineAddress) }}</a>
|
<a :href="event.onlineAddress">{{ urlToHostname(event.onlineAddress) }}</a>
|
||||||
</span>
|
</span>
|
||||||
@ -548,8 +548,12 @@ export default class Event extends EventMixin {
|
|||||||
return this.event.options.maximumAttendeeCapacity - this.event.participantStats.participants;
|
return this.event.options.maximumAttendeeCapacity - this.event.participantStats.participants;
|
||||||
}
|
}
|
||||||
|
|
||||||
urlToHostname(url: string): string {
|
urlToHostname(url: string): string|null {
|
||||||
|
try {
|
||||||
return (new URL(url)).hostname;
|
return (new URL(url)).hostname;
|
||||||
|
} catch (e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user