File tree 1 file changed +6
-3
lines changed
1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 3
3
// [À-ÖØ-ß]
4
4
// lower case ranges
5
5
// [à-öø-ÿ]
6
- export const magicSplit = / ^ [ a - z à - ö ø - ÿ ] + | [ A - Z À - Ö Ø - ß ] [ a - z à - ö ø - ÿ ] + | [ a - z à - ö ø - ÿ ] + | [ 0 - 9 ] + | [ A - Z À - Ö Ø - ß ] + (? ! [ a - z à - ö ø - ÿ ] ) / g;
6
+ export const magicSplit = / ^ [ a - z à - ö ø - ÿ а - я ] + | [ A - Z À - Ö Ø - ß А - Я ] [ a - z à - ö ø - ÿ а - я ] + | [ a - z à - ö ø - ÿ а - я ] + | [ 0 - 9 ] + | [ A - Z À - Ö Ø - ß А - Я ] + (? ! [ a - z à - ö ø - ÿ а - я ] ) / g;
7
7
export const spaceSplit = / \S + / g;
8
8
/**
9
9
* A string.matchAll function that will return an array of "string parts" and the indexes at which it split each part
@@ -45,7 +45,9 @@ export function splitAndPrefix(string, options) {
45
45
let part = _part ;
46
46
if ( keepSpecialCharacters === false ) {
47
47
if ( keep ) {
48
- part = part . normalize ( 'NFD' ) . replace ( new RegExp ( `[^a-zA-ZØßø0-9${ keep . join ( '' ) } ]` , 'g' ) , '' ) ;
48
+ part = part
49
+ . normalize ( 'NFD' )
50
+ . replace ( new RegExp ( `[^a-zA-ZØßø0-9${ keep . join ( '' ) } ]` , 'g' ) , '' ) ;
49
51
}
50
52
if ( ! keep ) {
51
53
part = part . normalize ( 'NFD' ) . replace ( / [ ^ a - z A - Z Ø ß ø 0 - 9 ] / g, '' ) ;
@@ -83,5 +85,6 @@ export function splitAndPrefix(string, options) {
83
85
export function capitaliseWord ( string ) {
84
86
const match = string . matchAll ( magicSplit ) . next ( ) . value ;
85
87
const firstLetterIndex = match ? match . index : 0 ;
86
- return string . slice ( 0 , firstLetterIndex + 1 ) . toUpperCase ( ) + string . slice ( firstLetterIndex + 1 ) . toLowerCase ( ) ;
88
+ return ( string . slice ( 0 , firstLetterIndex + 1 ) . toUpperCase ( ) +
89
+ string . slice ( firstLetterIndex + 1 ) . toLowerCase ( ) ) ;
87
90
}
You can’t perform that action at this time.
0 commit comments