RangerMauve / hypercore-fetch

Implementation of Fetch that uses the Hyper SDK for loading p2p content
MIT License
36 stars 12 forks source link

Append path to Link header #43

Closed josephmturner closed 1 year ago

josephmturner commented 1 year ago

Unlike the solution in v8.6.1:

const canonical = `hyper://${archive.key.toString('hex')}${path || ''}`
responseHeaders.Link = `<${canonical}>; rel="canonical"

it is not necessary to use pathname || '', since pathname will always contain at least '/'. In that case, Array.substring correctly leaves behind the empty string.

Resolves #42

RangerMauve commented 1 year ago

For future reference, string.substr is deprecated and should not be used. I've just pushed the fixes using a slightly different pattern in 9.0.3

josephmturner commented 1 year ago

Thank you - your solution is much nicer than mine.