|
|
|
@ -13,8 +13,8 @@ export const urlsafeSlugProcessor = string =>
|
|
|
|
|
decamelize: false,
|
|
|
|
|
lowercase: false
|
|
|
|
|
})
|
|
|
|
|
.replace(/DOLLAR/g, '$')
|
|
|
|
|
.replace(/DASH/g, '-');
|
|
|
|
|
.replace(/DOLLAR/g, '$')
|
|
|
|
|
.replace(/DASH/g, '-');
|
|
|
|
|
|
|
|
|
|
/* unicode-preserver processor */
|
|
|
|
|
|
|
|
|
@ -25,35 +25,35 @@ const isNonAlphaNumUnicode =
|
|
|
|
|
|
|
|
|
|
export const unicodeSafeProcessor = string =>
|
|
|
|
|
string.split('')
|
|
|
|
|
.reduce((accum, char, index, array) => {
|
|
|
|
|
const type = isNonAlphaNumUnicode(char) ? 'pass' : 'process';
|
|
|
|
|
|
|
|
|
|
if (index === 0) {
|
|
|
|
|
accum.current = {type, string: char};
|
|
|
|
|
} else if (type === accum.current.type) {
|
|
|
|
|
accum.current.string += char;
|
|
|
|
|
} else {
|
|
|
|
|
accum.chunks.push(accum.current);
|
|
|
|
|
accum.current = {type, string: char}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (index === array.length - 1) {
|
|
|
|
|
accum.chunks.push(accum.current);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return accum;
|
|
|
|
|
}, {chunks: [], current: {type: '', string: ''}})
|
|
|
|
|
.chunks
|
|
|
|
|
.reduce((accum, chunk) => {
|
|
|
|
|
const processed = chunk.type === 'process'
|
|
|
|
|
? urlsafeSlugProcessor(chunk.string)
|
|
|
|
|
: chunk.string;
|
|
|
|
|
|
|
|
|
|
processed.length > 0 && accum.push(processed);
|
|
|
|
|
|
|
|
|
|
return accum;
|
|
|
|
|
}, [])
|
|
|
|
|
.join(SLUG_SEPARATOR);
|
|
|
|
|
.reduce((accum, char, index, array) => {
|
|
|
|
|
const type = isNonAlphaNumUnicode(char) ? 'pass' : 'process';
|
|
|
|
|
|
|
|
|
|
if (index === 0) {
|
|
|
|
|
accum.current = {type, string: char};
|
|
|
|
|
} else if (type === accum.current.type) {
|
|
|
|
|
accum.current.string += char;
|
|
|
|
|
} else {
|
|
|
|
|
accum.chunks.push(accum.current);
|
|
|
|
|
accum.current = {type, string: char};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (index === array.length - 1) {
|
|
|
|
|
accum.chunks.push(accum.current);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return accum;
|
|
|
|
|
}, {chunks: [], current: {type: '', string: ''}})
|
|
|
|
|
.chunks
|
|
|
|
|
.reduce((accum, chunk) => {
|
|
|
|
|
const processed = chunk.type === 'process'
|
|
|
|
|
? urlsafeSlugProcessor(chunk.string)
|
|
|
|
|
: chunk.string;
|
|
|
|
|
|
|
|
|
|
processed.length > 0 && accum.push(processed);
|
|
|
|
|
|
|
|
|
|
return accum;
|
|
|
|
|
}, [])
|
|
|
|
|
.join(SLUG_SEPARATOR);
|
|
|
|
|
|
|
|
|
|
/* processor */
|
|
|
|
|
|
|
|
|
@ -74,5 +74,5 @@ export const makeSessionSlugProcessor = (preserveUnicode = false) => {
|
|
|
|
|
seen.add(slug);
|
|
|
|
|
|
|
|
|
|
return slug;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|