Skip to content

Commit

Permalink
Add sanitize lib for filename to avoid reserved character on specific…
Browse files Browse the repository at this point in the history
… filesystem
  • Loading branch information
Frogomeli committed May 1, 2019
1 parent ade9a4e commit b7a58f7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var FSChunkStore = require('fs-chunk-store')
var ImmediateChunkStore = require('immediate-chunk-store')
var peerDiscovery = require('torrent-discovery')
var bufferFrom = require('buffer-from')
var sanitize = require("sanitize-filename")

var blocklist = require('ip-set')
var exchangeMetadata = require('./lib/exchange-metadata')
Expand Down Expand Up @@ -131,7 +132,7 @@ var torrentStream = function (link, opts, cb) {
engine.store = ImmediateChunkStore(storage(torrent.pieceLength, {
files: torrent.files.map(function (file) {
return {
path: path.join(opts.path, file.path),
path: path.join(opts.path, sanitize(file.path)),
length: file.length,
offset: file.offset
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"peer-wire-swarm": "^0.12.0",
"rimraf": "^2.2.5",
"torrent-discovery": "^5.2.0",
"torrent-piece": "^1.0.0"
"torrent-piece": "^1.0.0",
"sanitize-filename": "^1.6.1"
},
"devDependencies": {
"buffer-alloc": "^1.1.0",
Expand Down

0 comments on commit b7a58f7

Please sign in to comment.