File tree Expand file tree Collapse file tree 4 files changed +17
-2
lines changed Expand file tree Collapse file tree 4 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 3636 "netlify-cms-ui-default" : " ^2.12.2" ,
3737 "react" : " ^16.8.4" ,
3838 "react-dom" : " ^16.8.4" ,
39- "react-select" : " ^3.1.0"
39+ "react-select" : " ^3.1.0" ,
40+ "slugify" : " ^1.5.0"
4041 },
4142 "devDependencies" : {
4243 "@babel/core" : " ^7.11.6" ,
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import React from 'react';
22import AsyncSelect from 'react-select/async' ;
33import { reactSelectStyles } from 'netlify-cms-ui-default/dist/esm/styles' ;
44import { NestedCollection } from './NestedCollection' ;
5+ import slugify from 'slugify' ;
56
67const trimStart = ( str , prefix ) => {
78 return str . substring ( prefix . length ) ;
@@ -44,7 +45,7 @@ const Option = (props) => {
4445
4546export const sanitizePath = ( path ) => {
4647 const replacement = '-' ;
47- const sanitizedPath = path . replace ( / [ ^ a - z 0 - 9 ] / gi , replacement ) . toLowerCase ( ) ;
48+ const sanitizedPath = slugify ( path . toLowerCase ( ) , replacement ) ;
4849
4950 // Remove any doubled or leading/trailing replacement characters (that were added in the sanitizers).
5051 const doubleReplacement = new RegExp ( `(?:${ replacement } )+` , 'g' ) ;
Original file line number Diff line number Diff line change @@ -20,4 +20,12 @@ describe('sanitizePath', () => {
2020 it ( 'should remove double replacer' , ( ) => {
2121 expect ( sanitizePath ( 'Who Are We' ) ) . toBe ( 'who-are-we' ) ;
2222 } ) ;
23+
24+ it ( 'should keep diacritis' , ( ) => {
25+ expect ( sanitizePath ( 'ăștia sunteți voi' ) ) . toBe ( 'astia-sunteti-voi' ) ;
26+ } ) ;
27+
28+ it ( 'should keep diacritis and remove whitespace, trailing and leading characters' , ( ) => {
29+ expect ( sanitizePath ( '?ăștia sunteți voi ? ' ) ) . toBe ( 'astia-sunteti-voi' ) ;
30+ } ) ;
2331} ) ;
Original file line number Diff line number Diff line change @@ -7015,6 +7015,11 @@ slice-ansi@^4.0.0:
70157015 astral-regex "^2.0.0"
70167016 is-fullwidth-code-point "^3.0.0"
70177017
7018+ slugify@^1.5.0 :
7019+ version "1.5.0"
7020+ resolved "https://registry.yarnpkg.com/slugify/-/slugify-1.5.0.tgz#5f3c8e2a84105b54eb51486db1b468a599b3c9b8"
7021+ integrity sha512-Q2UPZ2udzquy1ElHfOLILMBMqBEXkiD3wE75qtBvV+FsDdZZjUqPZ44vqLTejAVq+wLLHacOMcENnP8+ZbzmIA==
7022+
70187023snapdragon-node@^2.0.1 :
70197024 version "2.1.1"
70207025 resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b"
You can’t perform that action at this time.
0 commit comments