@@ -93,20 +93,26 @@ function updateTracklist() {
9393 labelColumn = document . createElement ( "div" ) ;
9494 const dummyImgSrc = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==' ;
9595
96- function getFirstCharacters ( inputString ) {
96+ function isHalfWidth ( char ) {
97+ // Check if the character is half-width based on its Unicode code point
98+ return ( char . codePointAt ( 0 ) <= 255 || ( char . codePointAt ( 0 ) >= 65281 && char . codePointAt ( 0 ) <= 65374 ) ) ;
99+ }
100+
101+ function getFirstCharacters ( inputString ) {
97102 // Split the input string into words
98103 const words = inputString . split ( ' ' ) ;
99-
104+
100105 // Extract the first two words
101106 const firstWord = words [ 0 ] ;
102107 const secondWord = words . length > 1 ? words [ 1 ] : '' ;
103-
104- // Get either one emoji or the first two letters
105- const firstCharacters = Array . from ( firstWord ) . slice ( 0 , 1 ) . join ( '' ) +
106- ( secondWord ? Array . from ( secondWord ) . slice ( 0 , 1 ) . join ( '' ) : '' ) ;
107-
108- return firstCharacters ;
109- }
108+ const firstCharacter = Array . from ( firstWord ) . slice ( 0 , 1 ) . join ( '' ) ;
109+ const secondCharacter = secondWord ? Array . from ( secondWord ) . slice ( 0 , 1 ) . join ( '' ) : '' ;
110+
111+ // Check if the first character of the first word is half-width
112+ const isFirstCharacterHalfWidth = isHalfWidth ( firstWord . charAt ( 0 ) ) ;
113+
114+ return firstCharacter + ( isFirstCharacterHalfWidth ? secondCharacter : '' ) ;
115+ }
110116
111117 ReactDOM . render (
112118 < div className = "spicetify-playlist-labels-labels-container" >
0 commit comments