mirror of
https://github.com/wagtail/wagtail.git
synced 2024-11-25 05:02:57 +01:00
Standardize on allowUnicode
for slugify util option
- This is the name used in the urlify util
This commit is contained in:
parent
d8e63954d8
commit
f0cf73f0d3
@ -63,9 +63,9 @@ export class SlugController extends Controller<HTMLInputElement> {
|
||||
event: CustomEvent<{ value: string }> | { detail: { value: string } },
|
||||
ignoreUpdate = false,
|
||||
) {
|
||||
const unicodeSlugsEnabled = this.allowUnicodeValue;
|
||||
const allowUnicode = this.allowUnicodeValue;
|
||||
const { value = this.element.value } = event?.detail || {};
|
||||
const newValue = slugify(value.trim(), { unicodeSlugsEnabled });
|
||||
const newValue = slugify(value.trim(), { allowUnicode });
|
||||
|
||||
if (!ignoreUpdate) {
|
||||
this.element.value = newValue;
|
||||
|
@ -12,7 +12,7 @@ describe('slugify', () => {
|
||||
});
|
||||
|
||||
describe('slugify with unicode slugs enabled', () => {
|
||||
const options = { unicodeSlugsEnabled: true };
|
||||
const options = { allowUnicode: true };
|
||||
|
||||
it('should return a correct slug', () => {
|
||||
expect(slugify('The Price is $72.00!', options)).toBe(
|
||||
|
@ -4,9 +4,9 @@
|
||||
*/
|
||||
export const slugify = (
|
||||
value: string,
|
||||
{ unicodeSlugsEnabled = false }: { unicodeSlugsEnabled?: boolean } = {},
|
||||
{ allowUnicode = false }: { allowUnicode?: boolean } = {},
|
||||
) =>
|
||||
unicodeSlugsEnabled
|
||||
allowUnicode
|
||||
? value
|
||||
.replace(/\s+/g, '-')
|
||||
.replace(/[&/\\#,+()$~%.'":`@^!*?<>{}]/g, '')
|
||||
|
Loading…
Reference in New Issue
Block a user