@@ -104,13 +104,6 @@ func Start(version string, spotifyBasePath string, extractedAppsPath string, fla
104104 readLocalCssMap (& cssTranslationMap )
105105 }
106106
107- cssMapPairs := make ([]string , 0 , len (cssTranslationMap )* 2 )
108- for k , v := range cssTranslationMap {
109- cssMapPairs = append (cssMapPairs , k , v )
110- }
111- cssMapJSReplacer := strings .NewReplacer (cssMapPairs ... )
112- cssMapJSStringRe := regexp .MustCompile (`"[^"]*"|'[^']*'|` + "`[^`]*`" + `|\b[a-zA-Z0-9_]{16,21}\s*:` )
113-
114107 verParts := strings .Split (flags .SpotifyVer , "." )
115108 spotifyMajor , spotifyMinor , spotifyPatch := 0 , 0 , 0
116109 if len (verParts ) > 0 {
@@ -266,19 +259,16 @@ func Start(version string, spotifyBasePath string, extractedAppsPath string, fla
266259 })
267260 }
268261
269- content = cssMapJSStringRe .ReplaceAllStringFunc (content , func (match string ) string {
270- first := match [0 ]
271- if first == '"' || first == '\'' || first == '`' {
272- inner := match [1 : len (match )- 1 ]
273- return string (first ) + cssMapJSReplacer .Replace (inner ) + string (first )
274- }
275- colonIdx := strings .LastIndex (match , ":" )
276- key := strings .TrimSpace (match [:colonIdx ])
277- if replaced , ok := cssTranslationMap [key ]; ok {
278- return `"` + replaced + `"` + match [colonIdx :]
279- }
280- return match
281- })
262+ for k , v := range cssTranslationMap {
263+ // Object keys
264+ utils .Replace (& content , `(` + k + `)(\s*:)` , func (submatches ... string ) string {
265+ return `"` + v + `"` + submatches [2 ]
266+ })
267+ // Remaining occurrences (inside string literals etc.)
268+ utils .Replace (& content , k , func (submatches ... string ) string {
269+ return v
270+ })
271+ }
282272 content = colorVariableReplaceForJS (content )
283273
284274 return content
0 commit comments