diff --git a/src/components/inspectors/ElementDestination.vue b/src/components/inspectors/ElementDestination.vue index 5a907d1f1..afaa3ad0c 100644 --- a/src/components/inspectors/ElementDestination.vue +++ b/src/components/inspectors/ElementDestination.vue @@ -50,7 +50,7 @@ :error="getValidationErrorForURL(externalURL)" data-cy="events-add-id" :placeholder="urlPlaceholder" - :helper="$t('Determine the URL where the request will end')" + :helper="externalUrlHelperText" data-test="external-url" /> { @@ -174,12 +180,26 @@ export default { }, methods: { getValidationErrorForURL(url) { + const isEmpty = typeof url !== 'string' || !url || !url.trim(); + if (isEmpty) { + if (this.destinationType === 'externalURL') { + return this.$t('URL is required when External URL is selected.'); + } + return ''; + } if (!this.isValidURL(url)) { - return this.$t('Must be a valid URL'); + return this.$t('Must be a valid URL or Mustache expressions') + ' ({{APP_URL}}, {{_request.id}}, {{_user.id}}, ' + this.$t('process variables') + ').'; } return ''; }, isValidURL(string) { + if (typeof string !== 'string' || !string.trim()) { + return false; + } + // Allow Mustache: same context as backend ({{APP_URL}}, {{_request.id}}, {{_user.id}}, process variables) + if (string.includes('{{')) { + return MUSTACHE_PATTERN.test(string); + } try { new URL(string); return true;