UNPKG

298 BJavaScriptView Raw
1"use strict";
2
3const path = require('path');
4const startsWith = require('mout/string/startsWith');
5
6module.exports = function(base, file) {
7 var rest = path.join.apply(path, arguments);
8 if(!startsWith(rest, base))
9 throw `path.jail escape attempt in ${base}/${file}`;
10 return rest;
11};