Skip to content
This repository was archived by the owner on Aug 12, 2023. It is now read-only.

Commit 3173794

Browse files
authored
Add support for new token images repository (#325)
1 parent 4ba91e1 commit 3173794

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/tokens/get-cdn-token-image-url.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ const getCdnTokenImageUrl = imageUrl => {
88
return `https://cdn.staticaly.com/gh/TrustWallet/tokens/master/tokens/${fileName}`;
99
}
1010

11+
if (
12+
imageUrl.startsWith(
13+
'https://raw.githubusercontent.com/TrustWallet/assets/master/blockchains/ethereum/assets/',
14+
)
15+
) {
16+
const path = imageUrl.substr(
17+
'https://raw.githubusercontent.com/TrustWallet/assets/master/blockchains/ethereum/assets/'
18+
.length,
19+
);
20+
return `https://cdn.staticaly.com/gh/TrustWallet/assets/master/blockchains/ethereum/assets/${path}`;
21+
}
22+
1123
return imageUrl;
1224
};
1325

src/tokens/get-cdn-token-image-url.test.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const getCdnTokenImageUrl = require('./get-cdn-token-image-url');
22

3-
it('should rewrite image urls to be served from CDN', () => {
3+
it('should rewrite image urls for tokens repository', () => {
44
const cdnUrl = getCdnTokenImageUrl(
55
'https://raw.githubusercontent.com/TrustWallet/tokens/master/tokens/0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359.png',
66
);
@@ -10,6 +10,16 @@ it('should rewrite image urls to be served from CDN', () => {
1010
);
1111
});
1212

13+
it('should rewrite image urls for assets repository', () => {
14+
const cdnUrl = getCdnTokenImageUrl(
15+
'https://raw.githubusercontent.com/TrustWallet/assets/master/blockchains/ethereum/assets/0x6B175474E89094C44Da98b954EedeAC495271d0F/logo.png',
16+
);
17+
18+
expect(cdnUrl).toBe(
19+
'https://cdn.staticaly.com/gh/TrustWallet/assets/master/blockchains/ethereum/assets/0x6B175474E89094C44Da98b954EedeAC495271d0F/logo.png',
20+
);
21+
});
22+
1323
it('should not transform non trust-wallet image urls', () => {
1424
const cdnUrl = getCdnTokenImageUrl('http://tmpuri.org/test.jpg');
1525

0 commit comments

Comments
 (0)