From 4dc960da8d1ece8700e41076da4bd3be6f29b591 Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Fri, 9 Dec 2022 11:21:02 +0000 Subject: [PATCH] [FIX] website: authorize again the trailing slash in SEO name field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit [1] improved the "sanitation" of this field for special character. For instance, when copy pasting the following terms: | Input | Before | After | |-----------------|------------------|-----------------| | fée d'été à 40€ | f-e-d-t-40- | fee-dete-a-40 | | Nội dung có Dấu | n-i-dung-c-d-u | noi-dung-co-dau | But it actually came with a bad behavior which was not noticed: it prevents to type `-` at the end of the input, which sounds good but is not. Indeed, when typing `a-word`, you will type `a` then try to type `-` which won't work as considering a (forbidden) trailing slash, even if you actually want to type something after. This commit allows trailing slashes again, it's not a big deal and one can remove it if he wants to. [1]: https://github.com/odoo/odoo/commit/bb43d4dbb5745be84f0f9462e768989e50607bea opw-3075419 closes odoo/odoo#107746 X-original-commit: bb43e343c0ec823dad8b102a81945b4a05a7af85 Signed-off-by: Romain Derie (rde) --- addons/website/static/src/components/dialog/seo.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/website/static/src/components/dialog/seo.js b/addons/website/static/src/components/dialog/seo.js index aadc4a3f718..b28f083aedf 100644 --- a/addons/website/static/src/components/dialog/seo.js +++ b/addons/website/static/src/components/dialog/seo.js @@ -339,8 +339,8 @@ class TitleDescription extends Component { // `NFKD` as in `http_routing` python `slugify()` ev.target.value = ev.target.value.trim().normalize('NFKD').toLowerCase() .replace(/\s+/g, '-') // Replace spaces with - - .replace(/[^\w-]+/g, '-') // Remove all non-word chars - .replace(/-\+/g, '-'); // Replace multiple - with single - + .replace(/[^\w-]+/g, '') // Remove all non-word chars + .replace(/--+/g, '-'); // Replace multiple - with single - this.seoContext.seoName = ev.target.value; } }