node-http-server
/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; |