1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Handling array type values for image in Identicon component (#13484)

* Handling array type values for image in Identicon component

* Adding additional type check
This commit is contained in:
ryanml 2022-02-01 20:11:42 -07:00
parent e2c4c512ba
commit 01844aef53

View File

@ -34,7 +34,7 @@ export default class Identicon extends PureComponent {
/**
* Used as the image source of the Identicon
*/
image: PropTypes.string,
image: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
/**
* Use the blockie type random image generator
*/
@ -76,7 +76,14 @@ export default class Identicon extends PureComponent {
const { className, diameter, alt, imageBorder, ipfsGateway } = this.props;
let { image } = this.props;
if (image.toLowerCase().startsWith('ipfs://')) {
if (Array.isArray(image) && image.length) {
image = image[0];
}
if (
typeof image === 'string' &&
image.toLowerCase().startsWith('ipfs://')
) {
image = getAssetImageURL(image, ipfsGateway);
}