-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Conversation
Thank you for submitting this PR!
Getting other community members to do a review would be great help too on complex PRs (you can ask in the chats/forums). If you are unsure about something, just leave us a comment.
We currently aim to provide initial feedback/triaging within two business days. Please keep an eye on any labelling actions, as these will indicate priorities and status of your contribution. |
Thanks for submitting this, sorry for the delay in reviewing. The problem this addresses is that passing a Uint8Array as a value to a URLSearchParams results in the E.g. Uint8Array.from([0, 1, 2]).toString()
// "0,1,2" So: new URLSearchParams({ data: Uint8Array.from([0, 1, 2]) }).toString()
// "data=0%2C1%2C2" This is then interpreted as a byte array encoded as an ascii string by the HTTP API server: decodeURIComponent('0%2C1%2C2')
// "0,1,2"
Uint8Array.from("0,1,2")
// Uint8Array(5) [0, 0, 1, 0, 2] This PR will fix the issue, but only where byte values can be represented as a string by JavaScript - note that for byte values 128-254 this is not the case: const bytes = Uint8Array.from([254])
// Uint8Array [254]
const str = new TextDecoder().decode(bytes)
// "�"
new TextEncoder().encode(str)
// Uint8Array(3) [239, 191, 189] Ascii/windows-1252 encoding doesn't quite do what you think it'd do either: const bytes = Uint8Array.from([254])
// Uint8Array [254]
const str = new TextDecoder('ascii').decode(bytes)
// "þ"
new TextEncoder().encode(str)
// Uint8Array(3) [195, 190]
encodeURIComponent("þ")
// "%C3%BE" This is what would end up being sent and I don't think go-IPFS will interpret For it to be interpreted as Really for this to be properly fixed in a way that doesn't require JS and go to agree on what 'URL encoded' means we need to be able to encode bytes sent in the query string. This is simple to do from the JS side but will need some coordination from go-IPFS. |
Writeup for encoding bytes sent in the query string in go-IPFS - ipfs/kubo#7958 |
Needs ipfs/kubo#7958 first. |
Thank you so much for opening this PR and for your patience in getting it merged. js-ipfs is being deprecated in favor of Helia. You can #4336 and read the migration guide.
If this is still a problem, a new PR should be opened against |
The http-client dht/put seems to refuse any possible key I can dream up to send it. It looks like its because its not operating on the same principle as dht/get.