only allow to click on valid website URLs

closes #8827
This commit is contained in:
Martin Raifer
2021-11-30 15:02:22 +01:00
parent 195e287923
commit 7015fae91c

View File

@@ -182,11 +182,17 @@ export function uiFieldText(field, context) {
function validIdentifierValueForLink() {
const value = utilGetSetValue(input).trim().split(';')[0];
const value = utilGetSetValue(input).trim();
if (field.type === 'url' && value) return value;
if (field.type === 'url' && value) {
try {
return (new URL(value)).href;
} catch (e) {
return null;
}
}
if (field.type === 'identifier' && field.pattern) {
return value && value.match(new RegExp(field.pattern));
return value && value.match(new RegExp(field.pattern))[0];
}
return null;
}