Link custom attribute shows "---" for valid URLs with TLD longer than 6 chars
Describe the bug
A contact custom attribute of type Link is shown as --- in the contact sidebar when the URL's TLD is longer than 6 characters (e.g. .exchange, .company, .digital). The value is saved correctly: it passes validation in the edit form, and opening the editor or copying the attribute gives the full URL. Only the display is wrong.
The display and the edit form validate URLs differently:
- The edit form uses vuelidate's
urlvalidator (CustomAttribute.vue#L131). - The display uses
isValidURLand falls back to'---'(CustomAttribute.vue#L89-L94):
urlValue() {
return isValidURL(this.value) ? this.value : '---';
},isValidURL (URLHelper.js#L62-L67) caps the TLD at 6 characters (\.[a-zA-Z0-9()]{1,6}\b):
/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/gmisValidURL('https://admin.example.com/users/123') // true
isValidURL('https://admin.example.exchange/users/123') // false -> rendered as '---'The same regex also rejects valid URLs that contain , ; ! $ ' * [ ] in the path or query, or non-ASCII characters.
To Reproduce
- Settings → Custom Attributes → add a contact attribute of type Link.
- Open a contact and set the attribute to
https://admin.example.exchange/users/123. - Save. The editor accepts the value.
- The sidebar shows
---instead of the link.
Expected behavior
Any URL the edit form accepts is shown as a clickable link. One option is to use the same validator for display and for editing. Another is to replace the regex in isValidURL with a new URL(value) check limited to http:/https:.
Environment
Kubernetes (self-hosted), Chatwoot v4.18.0. The code is unchanged on develop.
Source: chatwoot/chatwoot