diff options
| author | Samuel Degueldre <sad@odoo.com> | 2020-10-05 11:13:50 +0000 |
|---|---|---|
| committer | Samuel Degueldre <sad@odoo.com> | 2020-10-05 11:13:50 +0000 |
| commit | 7558dcce791f707e3f3470835133f91ec7ff074f (patch) | |
| tree | df7a9ee632644c6b5dccb1fe09cf1e0709c1520f /addons/web_editor/static/src/js/common/utils.js | |
| parent | 8f4b2eefded0e8415b12804f26467f209878cd21 (diff) | |
[FIX] web_editor: fix background-image urls becoming absolute on drop
With the recent addition of the parallax option on all snippets,
background-image urls were being converted from relative to absolute on
snippet-drop. This was caused by trying to read the background-image's
url and setting it back onto the target, but there is no way to reliably
read a background-image url in relative form, so it was returned in
absolute form and then written back to the element as is.
This commit fixes that by always converting the absolute URL to relative
when they are on the same origin as the database.
task-2312878
closes odoo/odoo#59098
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Diffstat (limited to 'addons/web_editor/static/src/js/common/utils.js')
| -rw-r--r-- | addons/web_editor/static/src/js/common/utils.js | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/addons/web_editor/static/src/js/common/utils.js b/addons/web_editor/static/src/js/common/utils.js index 6e92bd6955b..8beeca4f26e 100644 --- a/addons/web_editor/static/src/js/common/utils.js +++ b/addons/web_editor/static/src/js/common/utils.js @@ -224,6 +224,11 @@ function _getBgImageURL(el) { if (!match) { return ''; } + const fullURL = new URL(match[2]); + // Make URL relative if possible + if (fullURL.origin === window.location.origin) { + return fullURL.href.slice(fullURL.origin.length); + } return match[2]; } |
