Skip to content

Conversation

@drichar
Copy link
Collaborator

@drichar drichar commented May 19, 2025

Description

This PR enhances the IPFS utility to properly resolve NFD avatar URLs into browser-displayable HTTPS links. It adds robust content validation to ensure the resolved URLs point to actual images, with special handling for NFT-style JSON metadata that may contain nested image references.

Details

  • Add content type validation to ensure resolved URLs point to actual images
  • Handle NFT metadata JSON that contains nested image references
  • Support both direct IPFS image files and JSON metadata containing image URLs
  • Implement smart fallback chain:
    • Try NFD's optimized image CDN first
    • Fall back to IPFS gateway for direct images
    • Handle JSON metadata by extracting and validating image URLs
    • Support both IPFS and HTTP image URLs in metadata
  • Add comprehensive test coverage to verify URL resolution behavior
  • Update CI pipeline to include automated testing

drichar added 3 commits May 18, 2025 20:07
…cation

Improve the `checkIpfsAvailability` utility to properly verify image content
types from IPFS sources. The enhanced function now checks content types from
both gateways, handles JSON metadata by extracting embedded image URLs, and
properly verifies that returned URLs point to image resources only.

This makes the IPFS handling more robust by ensuring we only return valid
image URLs and properly handle metadata files that contain references to
image assets.
Configure Vitest testing setup for the React package with Node.js environment
and create comprehensive test coverage for the `checkIpfsAvailability` utility.
The tests cover various IPFS content scenarios including image type
verification, JSON metadata handling, and fallback behavior.
}

const cid = url.replace('ipfs://', '')
const nfdUrl = `https://images.nf.domains/ipfs/${cid}`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we'll need to point to something else in the future but definitely fine for now.

@drichar drichar merged commit fab5501 into main Jul 8, 2025
1 check passed
@drichar drichar deleted the feat/enhance-ipfs-nfd-avatar-handling branch July 8, 2025 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants