webtorrent / create-torrent

Create .torrent files
https://webtorrent.io
MIT License
341 stars 94 forks source link

Fix: browser path handling #117

Closed codealchemist closed 4 years ago

codealchemist commented 4 years ago

What is the purpose of this pull request? (put an "X" next to item)

[ ] Documentation update [x] Bug fix [ ] New feature [ ] Other, please explain:

What changes did you make? (Give an overview)

Which issue (if any) does this pull request address? Uncaught TypeError: item.path.shift is not a function at index.js:132

Is there anything you'd like reviewers to focus on? The issue happened when passing an array of File objects to WebTorrent's seed method. Tested using react-dropzone.

codealchemist commented 4 years ago

For some reason react-dropzone is forcing the path to be the filename when it's not available: https://github.com/react-dropzone/file-selector/blob/master/src/file.ts#L30

Not sure if that's valid, but this PR will fix issues with react-dropzone and all tests passed. I wonder if this change could create any other issue. Feedback is welcome. Thx!

codealchemist commented 4 years ago

Still thinking about this one... If adding the filename to the path is a non standard practice I might better create a PR against react-dropzone repo to change it. :)