node-http-server

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 34  →  ?path2? @ 35
/src/was.js
@@ -0,0 +1,17 @@
#!/usr/bin/env node
 
/*************************************************************************/
/* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */
/*************************************************************************/
 
// Checks whether userPath is a child of rootPath.
var was = {
isRooted: function(userPath, rootPath, separator, callback) {
userPath = userPath.split(separator).filter(Boolean);
rootPath = rootPath.split(separator).filter(Boolean);
callback(userPath.length >= rootPath.length &&
rootPath.every((e, i) => e === userPath[i]));
}
}
 
module.exports = was;