[IMP] web_editor: omit protocol in URL input field

Before this commit, when an existing link was edited with the LinkTools
or LinkDialog, the URL input field omitted the "mailto:" part of the URL
for email links, but displayed the protocol/scheme for http(s) links and
phone numbers (tel: or tel://).

This commit standardizes the behaviour of the referred input field such
that the protocol/scheme for http(s), mailto and tel URLs are omitted,
in order to have a cleaner UI.

task-3516854

Part-of: odoo/odoo#136487
This commit is contained in:
Rodolpho Lima
2023-09-29 09:21:52 +00:00
parent 6d4a3b3ab5
commit 69a27360c9
2 changed files with 3 additions and 3 deletions
@@ -196,8 +196,8 @@ export class Link extends Component {
*/
_setUrl({ shouldFocus } = {}) {
if (this.state.url) {
var match = /mailto:(.+)/.exec(this.state.url);
this.$el.find('input[name="url"]').val(match ? match[1] : this.state.url);
const protocolLessUrl = this.state.url.replace(/^(https?|mailto|tel):(\/\/)?/i, '');
this.$el.find('input[name="url"]').val(protocolLessUrl);
this._onURLInput();
this._savedURLInputOnDestroy = false;
}
@@ -285,7 +285,7 @@ wTourUtils.registerWebsitePreviewTour('link_tools', {
content: "Check Link tools URL input content is up-to-date",
trigger: "#o_link_dialog_url_input",
run() {
if (this.$anchor[0].value !== 'http://callmemaybe.com/shop') {
if (this.$anchor[0].value !== 'callmemaybe.com/shop') {
throw new Error("Tour step failed");
}
}