-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: detect cids in query parameters #31
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Some non blocking comments:
- The
findCIDPathInURL
andfindCIDPathInURLComponent
return empty strings when a CID is not found. Wondering if it is better to throw errors in these scenarios as it forces who ever is using those functions to explicitly handle that case. Also makes it easier to understand the expected behavior of the function - The
findCIDPathInUrlComponent
function does a lot of string manipulation. I think some comments would help understand what is happening in the function. In the case we need to add support for more URL format, would also make it easier to understand the code and make necessary changes.
I think it's better to return null. It's expected that functions that find/search stuff may not find anything, e.g.
good point i'll add some comments |
agree with eric here. if the function was prior art for context: regex libs dont throw an error when you search a string for a match and none is found. they just return no matches, eg an empty list 🙂 and agree with amean that comments with examples helpful! 🙌 my 2c either way, awesome PR guys 🙌 |
Handles #30
CID + path detection is now 1 function instead of 2, and works in these cases:
bafybeidrf56yzbkocajbloyafrebrdzsam3uj35sce2fdyo4elb6zzoily.ipfs.dweb.link/cat.png
https://ipfs.io/ipfs/bafybeidrf56yzbkocajbloyafrebrdzsam3uj35sce2fdyo4elb6zzoily/cat.png
https://proxy.com/?url=ipfs.io%2Fipfs%2Fbafybeidrf56yzbkocajbloyafrebrdzsam3uj35sce2fdyo4elb6zzoily%2Fcat.png
https://proxy.com/?url=bafybeidrf56yzbkocajbloyafrebrdzsam3uj35sce2fdyo4elb6zzoily.ipfs.dweb.link%2Fcat.png