Skip to content

Commit

Permalink
fix: remove commas from key
Browse files Browse the repository at this point in the history
  • Loading branch information
sketchbuch committed Jan 17, 2024
1 parent 6af85ba commit 07cccfd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/utils/strings/cleanFileIconKey.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe('Utils > Strings > cleanFileIconKey()', () => {
{ cleanedKey: 'some-key', key: 'some/key', replace: '/', search: '.' },
{ cleanedKey: 'cpp', key: 'c++', replace: 'p', search: '+' },
{ cleanedKey: 'ch', key: 'c#', replace: 'h', search: '#' },
{ cleanedKey: 'puppeteer', key: 'puppeteer,', replace: '', search: ',' },
]

testKeys.forEach((testObj) => {
Expand Down
7 changes: 6 additions & 1 deletion src/utils/strings/cleanFileIconKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@
* Replaces characters in file icon keys that result in invalid CSS selectors.
*/
export const cleanFileIconKey = (fileIconKey: string): string => {
return fileIconKey.replace(/\./g, '-').replace(/\//g, '-').replace(/\+/g, 'p').replace(/#/g, 'h')
return fileIconKey
.replace(/\./g, '-')
.replace(/\//g, '-')
.replace(/\+/g, 'p')
.replace(/#/g, 'h')
.replace(/,/g, '') // See: https://github.com/sketchbuch/vsc-workspace-sidebar/issues/112
}

0 comments on commit 07cccfd

Please sign in to comment.