@@ -50,25 +50,30 @@ function fetchLocalTokenIcons(network: Network): PartialTokenInfoMap {
5050
5151 const localImages : string [ ] = fs . readdirSync ( 'src/assets/images/tokens' )
5252 localImages . map ( ( imageName ) => {
53- let address : string
54- const fileName = imageName . split ( '.png' ) [ 0 ]
53+ const match = imageName . match ( / ^ ( . + ) \. ( p n g | s v g ) $ / )
54+ if ( ! match ) return
5555
56- if ( ! isAddress ( fileName ) ) {
56+ const fileName = match [ 1 ]
57+ const fileExtension = match [ 2 ]
58+
59+ if ( fileName && ! isAddress ( fileName ) ) {
5760 const [ _network , _address ] = ( fileName as string ) . split ( '_' )
5861 if ( _network === network && isAddress ( _address ) ) {
59- address = _address
60- } else {
61- return
62+ tokenIcons . push ( {
63+ address : getAddress ( _address ) ,
64+ logoURI : `https://raw.githubusercontent.com/burrbear-dev/tokenlists/main/src/assets/images/tokens/${ (
65+ fileName as string
66+ ) . toLowerCase ( ) } .${ fileExtension } `,
67+ } )
6268 }
6369 } else {
64- address = fileName
70+ tokenIcons . push ( {
71+ address : getAddress ( fileName ) ,
72+ logoURI : `https://raw.githubusercontent.com/burrbear-dev/tokenlists/main/src/assets/images/tokens/${ (
73+ fileName as string
74+ ) . toLowerCase ( ) } .${ fileExtension } `,
75+ } )
6576 }
66-
67- tokenIcons . push ( {
68- address : getAddress ( address ) ,
69- // eslint-disable-next-line max-len
70- logoURI : `https://raw.githubusercontent.com/burrbear-dev/tokenlists/main/src/assets/images/tokens/${ fileName . toLowerCase ( ) } .png` ,
71- } )
7277 } )
7378
7479 return convertTokenInfoToMap ( tokenIcons as TokenInfo [ ] )
0 commit comments