Skip to content

fix(storage): normalize custom gatewayUrl in IPFSStorage.upload (#504) - #511

Open
aazminu wants to merge 1 commit into
trustflow-protocol:mainfrom
aazminu:fix/504
Open

aazminu wants to merge 1 commit into
trustflow-protocol:mainfrom
aazminu:fix/504

Conversation

@aazminu

@aazminu aazminu commented Oct 17, 2026

Copy link
Copy Markdown

Pull Request

Description

Factors gateway URL normalization (replace(/\/+$/, '') + ensuring the /ipfs path segment) out of IPFSStorage.resolve() into shared helpers (normalizeGatewayUrl and buildGatewayCidUrl) and uses buildGatewayCidUrl in IPFSStorage.upload(). This ensures upload() returns the exact same gateway URL that resolve() requests when a custom gatewayUrl is configured without an /ipfs suffix or with trailing slashes.

Linked Issue

Closes #504

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change — see docs/VERSIONING.md; add a ### ⚠️ Breaking Changes changelog entry and a docs/UPGRADING.md section)
  • Documentation update
  • Dependency update
  • Refactor (no functional changes)

Checklist

Code Quality

  • TypeScript strict mode: no any types in public APIs
  • All public functions have JSDoc comments
  • Code follows the project's style (run npm run format:check to verify)
  • Linting passes: npm run lint
  • Type checking passes: npm run typecheck (and npm run typecheck:tests if tests were modified)

Testing

  • Tests added or updated for new/changed functionality
  • Tests pass: npm run test
  • Test coverage maintained or improved (run npm run test:coverage to check)
  • No unrelated test changes

Documentation

  • CHANGELOG.md updated with entry under [Unreleased] section, formatted as:
    - Issue #504: Factored gateway URL normalization out of `IPFSStorage.resolve` into a shared helper used by both `upload()` and `resolve()` so custom gateways without an `/ipfs` suffix return consistent gateway URLs.
  • README updated if user-facing features changed
  • API documentation (docs/API.md) updated if public API changed
  • Architecture documentation (docs/ARCHITECTURE.md) updated if module structure/patterns changed
  • JSDoc comments are clear and include examples for complex functions

General

  • No console.log() or debug code left behind
  • No unrelated files committed
  • Branch follows convention: fix/[issue-number] or feature/[description]
  • Commit messages are descriptive and reference issue numbers where applicable

Notes

Verified with npx jest tests/storage.test.ts tests/storage-resolve.test.ts, npm run typecheck, npm run lint, and npx prettier --check.

@aazminu
aazminu requested a review from meshackyaro as a code owner October 17, 2026 11:02
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.

IPFSStorage.upload's returned gateway URL disagrees with resolve's URL construction for custom gateways

1 participant