Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
worker: simplify filename checks
Replace a couple of checks with a single regular expression.
  • Loading branch information
BridgeAR committed Apr 14, 2019
commit cffb4983730fdce034b921876559c1d9d7fbaed6
6 changes: 1 addition & 5 deletions lib/internal/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,7 @@ class Worker extends EventEmitter {
options.execArgv);
}
if (!options.eval) {
if (!path.isAbsolute(filename) &&
!filename.startsWith('./') &&
!filename.startsWith('../') &&
!filename.startsWith('.' + path.sep) &&
!filename.startsWith('..' + path.sep)) {
if (!path.isAbsolute(filename) && !/^\.\.?[\\/]/.test(filename)) {
throw new ERR_WORKER_PATH(filename);
}
filename = path.resolve(filename);
Expand Down