Why an ENS contenthash starts with two bytes for the IPFS namespace
A website gateway strips one byte from an ENS contenthash and hands the remainder to its CID decoder. Every link fails even though an independent ENS client opens the site.
Decode the protocol prefix before the content identifier
The prefix is an unsigned varint. In this truncated fixture, e3 01 encodes protocol number 0xe3; the following 01 70 begins the CID. The example illustrates just this two-byte prefix. In production, use a bounded varint decoder and the consumed length instead of assuming all protocol codes take two bytes.
const bytes = Uint8Array.from([0xe3, 0x01, 0x01, 0x70]);
const protocol = (bytes[0] & 0x7f) | ((bytes[1] & 0x7f) << 7);
console.log(protocol.toString(16), bytes.slice(2));
Select a resolver for the decoded protocol
For IPFS, pass the complete remaining CID bytes to a CID library, validate them, then form the gateway URL. The short fixture deliberately contains no complete CID and cannot resolve to a file. Other protocol codes may have different payload formats. Preserve the original record and distinguish an unsupported protocol from a malformed CID when reporting a broken name.