[FIX] website: authorize again the trailing slash in SEO name field

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) <rde@odoo.com>
This commit is contained in:
Romain Derie
2022-12-12 16:16:43 +01:00
parent 8ae9212b15
commit 4dc960da8d
@@ -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;
}
}