mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-26 06:08:40 +01:00
* feat: improvements covering solana nfts(send, ownership badge, persistent imports etc), closing emptied token accounts and other fixes from patch * feat: more improvements for nfts including security hardening * fix: display error in full
26 lines
570 B
Dart
26 lines
570 B
Dart
const _ipfsGateway = "https://ipfs.io/ipfs/";
|
|
const _ipfsScheme = "ipfs://";
|
|
|
|
String? tryNormalizeIpfsUrl(String? url) {
|
|
if (url == null) {
|
|
return null;
|
|
}
|
|
|
|
if (!url.toLowerCase().startsWith(_ipfsScheme)) {
|
|
return url.toLowerCase().startsWith("https://") ? url : null;
|
|
}
|
|
|
|
var cid = url.substring(_ipfsScheme.length);
|
|
|
|
// Some minters write ipfs://ipfs/<cid>, which would double the gateway path.
|
|
if (cid.toLowerCase().startsWith("ipfs/")) {
|
|
cid = cid.substring(5);
|
|
}
|
|
|
|
if (cid.isEmpty) {
|
|
return null;
|
|
}
|
|
|
|
return "$_ipfsGateway$cid";
|
|
}
|