[FIX] web_editor: link with @ open new window option
Before this commit, when using the LinkTools (website, mass_mailing), if an http URL contained a "@" (ex: https://www.youtube.com/@iRopes), it got incorrectly recognized as an e-mail URL and the option to open the link in a new windown was hidden from the UI. This commit fixes the issue by making the test for e-mail URL slightly more robust than just checking for the presence of a "@". task-3356685 opw-3349704 closes odoo/odoo#125742 X-original-commit: 3f1db2397e50b26e2658d270cbb7ce908d5c05cd Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
@@ -55,6 +55,7 @@ export const URL_REGEX = new RegExp(`((?:(?:${httpRegex}${urlRegexBase}))`, 'gi'
|
||||
export const URL_REGEX_WITH_INFOS = new RegExp(`((?:(?:${httpCapturedRegex}${urlRegexBase}))`, 'gi');
|
||||
export const YOUTUBE_URL_GET_VIDEO_ID =
|
||||
/^(?:(?:https?:)?\/\/)?(?:(?:www|m)\.)?(?:youtube\.com|youtu\.be)(?:\/(?:[\w-]+\?v=|embed\/|v\/)?)([^\s?&#]+)(?:\S+)?$/i;
|
||||
export const EMAIL_REGEX = /^(mailto:)?[\w-.]+@(?:[\w-]+\.)+[\w-]{2,4}$/i;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Position and sizes
|
||||
|
||||
@@ -7,6 +7,7 @@ import {isColorGradient} from "web_editor.utils";
|
||||
|
||||
const getDeepRange = OdooEditorLib.getDeepRange;
|
||||
const getInSelection = OdooEditorLib.getInSelection;
|
||||
const EMAIL_REGEX = OdooEditorLib.EMAIL_REGEX;
|
||||
const _t = core._t;
|
||||
|
||||
/**
|
||||
@@ -568,7 +569,7 @@ const Link = Widget.extend({
|
||||
this._savedURLInputOnDestroy = true;
|
||||
var $linkUrlInput = this.$('#o_link_dialog_url_input');
|
||||
let value = $linkUrlInput.val();
|
||||
let isLink = value.indexOf('@') < 0;
|
||||
let isLink = !EMAIL_REGEX.test(value);
|
||||
this._getIsNewWindowFormRow().toggleClass('d-none', !isLink);
|
||||
this.$('.o_strip_domain').toggleClass('d-none', value.indexOf(window.location.origin) !== 0);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user