mirror of
https://github.com/wagtail/wagtail.git
synced 2024-11-29 01:22:07 +01:00
Fix issue where allow unicode slugs was not correctly used for urlify (#11865)
When the urlify util is used, ensure that we pass in the allow unicode value correctly in the SlugController. Note: This was passed in for slugify but the usage of slugify, not urlify. Fixes #11828
This commit is contained in:
parent
b21b1a1534
commit
2d075177c4
@ -58,6 +58,7 @@ Changelog
|
||||
* Fix: Retain query parameters when switching between locales in the page chooser (Abdelrahman Hamada, Sage Abdullah)
|
||||
* Fix: Add `w-kbd-scope-value` with support for `global` so that specific keyboard shortcuts (e.g. ctrl+s/cmd+s) trigger consistently even when focused on fields (Neeraj Yetheendran)
|
||||
* Fix: Improve exception handling when generating image renditions concurrently (Andy Babic)
|
||||
* Fix: Respect `WAGTAIL_ALLOW_UNICODE_SLUGS` setting when auto-generating slugs (LB (Ben) Johnston)
|
||||
* Docs: Add contributing development documentation on how to work with a fork of Wagtail (Nix Asteri, Dan Braghis)
|
||||
* Docs: Make sure the settings panel is listed in tabbed interface examples (Tibor Leupold)
|
||||
* Docs: Update content and page names to their US spelling instead of UK spelling (Victoria Poromon)
|
||||
|
@ -45,7 +45,7 @@ describe('SlugController', () => {
|
||||
expect(slugInput.value).toEqual('visiter-toulouse-en-t-2025');
|
||||
});
|
||||
|
||||
it('should now allow unicode characters by default', () => {
|
||||
it('should allow unicode characters when allow-unicode-value is set to truthy', () => {
|
||||
const slugInput = document.querySelector('#id_slug');
|
||||
slugInput.setAttribute('data-w-slug-allow-unicode-value', 'true');
|
||||
|
||||
@ -267,7 +267,7 @@ describe('urlify behaviour', () => {
|
||||
expect(slugInput.value).toBe('urlify-testing-on-edit-page');
|
||||
});
|
||||
|
||||
it('should transform input with special characters to their ASCII equivalent', () => {
|
||||
it('should transform input with special (unicode) characters to their ASCII equivalent by default', () => {
|
||||
const slugInput = document.getElementById('id_slug');
|
||||
slugInput.value = 'Some Title with éçà Spaces';
|
||||
|
||||
@ -280,6 +280,21 @@ describe('urlify behaviour', () => {
|
||||
expect(slugInput.value).toBe('some-title-with-eca-spaces');
|
||||
});
|
||||
|
||||
it('should transform input with special (unicode) characters to keep unicode values if allow unicode value is truthy', () => {
|
||||
const value = 'Dê-me fatias de pizza de manhã --ou-- à noite';
|
||||
|
||||
const slugInput = document.getElementById('id_slug');
|
||||
slugInput.setAttribute('data-w-slug-allow-unicode-value', 'true');
|
||||
|
||||
slugInput.value = value;
|
||||
|
||||
const event = new CustomEvent('custom:event', { detail: { value } });
|
||||
|
||||
document.getElementById('id_slug').dispatchEvent(event);
|
||||
|
||||
expect(slugInput.value).toBe('dê-me-fatias-de-pizza-de-manhã-ou-à-noite');
|
||||
});
|
||||
|
||||
it('should return an empty string when input contains only special characters', () => {
|
||||
const slugInput = document.getElementById('id_slug');
|
||||
slugInput.value = '$$!@#$%^&*';
|
||||
|
@ -89,12 +89,12 @@ export class SlugController extends Controller<HTMLInputElement> {
|
||||
event: CustomEvent<{ value: string }> | { detail: { value: string } },
|
||||
ignoreUpdate = false,
|
||||
) {
|
||||
const allowUnicode = this.allowUnicodeValue;
|
||||
const { value = this.element.value } = event?.detail || {};
|
||||
|
||||
const trimmedValue = value.trim();
|
||||
|
||||
const newValue =
|
||||
urlify(trimmedValue) ||
|
||||
urlify(trimmedValue, { allowUnicode }) ||
|
||||
this.slugify({ detail: { value: trimmedValue } }, true);
|
||||
|
||||
if (!ignoreUpdate) {
|
||||
|
@ -87,6 +87,7 @@ This feature was developed by Ben Enright and Thibaud Colas.
|
||||
* Retain query parameters when switching between locales in the page chooser (Abdelrahman Hamada, Sage Abdullah)
|
||||
* Add `w-kbd-scope-value` with support for `global` so that specific keyboard shortcuts (e.g. ctrl+s/cmd+s) trigger consistently even when focused on fields (Neeraj Yetheendran)
|
||||
* Improve exception handling when generating image renditions concurrently (Andy Babic)
|
||||
* Respect `WAGTAIL_ALLOW_UNICODE_SLUGS` setting when auto-generating slugs (LB (Ben) Johnston)
|
||||
|
||||
|
||||
### Documentation
|
||||
|
Loading…
Reference in New Issue
Block a user