This repository was archived by the owner on Mar 10, 2020. It is now read-only.
fix(files): ensure throw meaningful error for unsupported encoding in cat()#804
Open
0x-r4bbit wants to merge 1 commit intoipfs-inactive:masterfrom
Open
fix(files): ensure throw meaningful error for unsupported encoding in cat()#8040x-r4bbit wants to merge 1 commit intoipfs-inactive:masterfrom
cat()#8040x-r4bbit wants to merge 1 commit intoipfs-inactive:masterfrom
Conversation
Author
|
@alanshaw maybe you can leave a quick comment on https://github.com/ipfs/js-ipfs-api/issues/799#issuecomment-402466066 I'll put this PR is shape right away then :) |
alanshaw
reviewed
Jul 17, 2018
src/files/cat.js
Outdated
| hash = cleanCID(hash) | ||
| if (checkValidInput(hash)) { | ||
| hash = cleanCID(hash) | ||
| } |
Contributor
There was a problem hiding this comment.
I think you're right, we should delegate the parameter checking to the IPFS node we're calling so not to duplicate the logic and have to keep two sets of the same code in sync. We just need to serialize valid inputs that aren't already serialized. Could we simply do something like this?:
try {
hash = typeof hash === 'string' ? hash : cleanCID(hash)
} catch (err) {
return callback(err)
}
Author
There was a problem hiding this comment.
Sure that could work I'll update the and also look into if and how this can be tested.
cat() command is only cleaned when input …cat()
cat()cat()
Author
|
@alanshaw this is now updated. A test for verification can be found here ipfs-inactive/interface-js-ipfs-core#330 |
A test to verify this is available at ipfs-inactive/interface-js-ipfs-core#330 and needs to be merged first. Fixes #799 License: MIT Signed-off-by: Pascal Precht pascal.precht@gmail.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A test to verify this is available at ipfs-inactive/interface-js-ipfs-core#330 and needs to be merged first.
Fixes #799
License: MIT
Signed-off-by: Pascal Precht pascal.precht@gmail.com