[FIX] web_editor: mailto url link tools

Before this commit:

When trying to edit a link with mailto, there is an "https://"
added and preventing the link to work successfully

After this commit:

The mailto part of the link is correctly kept as is and the link works.

Task-2961012
Task-2977682

closes odoo/odoo#104064

X-original-commit: a22d6d1859a8f97c3cccdba755392cd13d7eb866
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
dhba-odoo
2022-10-25 15:03:41 +02:00
committed by David Monjoie
parent cea5ee91ca
commit f7356f6a19
@@ -299,7 +299,10 @@ const Link = Widget.extend({
(type && size ? (' btn-' + size) : '');
var isNewWindow = this._isNewWindow(url);
var doStripDomain = this._doStripDomain();
if (url.indexOf('@') >= 0 && url.indexOf('mailto:') < 0 && !url.match(/^http[s]?/i)) {
if (
url.indexOf('@') >= 0 && url.indexOf('mailto:') < 0 && !url.match(/^http[s]?/i) ||
this._link && this._link.href.includes('mailto:') && !url.includes('mailto:')
) {
url = ('mailto:' + url);
} else if (url.indexOf(location.origin) === 0 && doStripDomain) {
url = url.slice(location.origin.length);