Skip to content

Commit

Permalink
fix(gateway): fix multicodec during IPNS redirect
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Marcin Rataj <[email protected]>
  • Loading branch information
lidel committed Jan 27, 2020
1 parent 56f057e commit a2af834
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/corehttp/hostname.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,13 @@ func toSubdomainURL(host, path string) (url string, ok bool) {
// if object turns out to be a valid CID,
// ensure text representation used in subdomain is CIDv1 in Base32
// https://github.com/ipfs/in-web-browsers/issues/89
object = cid.NewCidV1(rootCid.Type(), rootCid.Hash()).String()
cidType := rootCid.Type()
if ns == "ipns" && cidType != cid.Libp2pKey {
// CIDv1 in IPNS should use libp2p-key multicodec
// Here we have CIDv0 that needs to be upgraded and fixed
cidType = cid.Libp2pKey
}
object = cid.NewCidV1(cidType, rootCid.Hash()).String()
}

return fmt.Sprintf(
Expand Down

0 comments on commit a2af834

Please sign in to comment.