Fix diacritics downcoding in slugs

This change correctly downcodes diacritics to ASCII if user has WAGTAIL_ALLOW_UNICODE_SLUGS = False (e.g. abčďéfg -> abcdefg)
Without this change, the slug simply strips all diacritics which is not ideal (e.g. abčďěfg -> abfg)
This commit is contained in:
Ondřej Šodek 2018-12-12 19:09:56 +01:00 committed by GitHub
parent e7adf51d2a
commit 4614b5faa4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,13 +8,13 @@ $(document).ready(function () {
$('#id_title_' + lang_code).on('focus', function () {
/* slug should only follow the title field if its value matched the title's value at the time of focus */
var currentSlug = $('#id_slug_' + lang_code).val();
var slugifiedTitle = cleanForSlug(this.value);
var slugifiedTitle = cleanForSlug(this.value, true);
slugFollowsTitle = (currentSlug == slugifiedTitle);
});
$('#id_title_' + lang_code).on('keyup keydown keypress blur', function () {
if (slugFollowsTitle) {
var slugifiedTitle = cleanForSlug(this.value);
var slugifiedTitle = cleanForSlug(this.value, true);
$('#id_slug_' + lang_code).val(slugifiedTitle);
}
});