mirror of https://github.com/Budibase/budibase.git
26 changed files with 77 additions and 86 deletions
@ -1,3 +1,3 @@ |
|||||
const { join } = require("../sanitisedPath") |
const { join } = require("../centralPath") |
||||
|
|
||||
module.exports = (appPath, pageName) => join(appPath, "public", pageName) |
module.exports = (appPath, pageName) => join(appPath, "public", pageName) |
||||
|
|||||
@ -0,0 +1,22 @@ |
|||||
|
const path = require("path") |
||||
|
|
||||
|
// this simply runs all of our path join and resolve functions through
|
||||
|
// a central location incase we need to add some protection to file paths
|
||||
|
|
||||
|
/** |
||||
|
* Exactly the same as path.join |
||||
|
* @param args Any number of string arguments to add to a path |
||||
|
* @returns {string} The final path ready to use |
||||
|
*/ |
||||
|
exports.join = function(...args) { |
||||
|
return path.join(...args) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Exactly the same as path.resolve |
||||
|
* @param args Any number of string arguments to add to a path |
||||
|
* @returns {string} The final path ready to use |
||||
|
*/ |
||||
|
exports.resolve = function(...args) { |
||||
|
return path.resolve(...args) |
||||
|
} |
||||
@ -1,38 +0,0 @@ |
|||||
const path = require("path") |
|
||||
|
|
||||
const regex = new RegExp(/:(?![\\/])/g) |
|
||||
|
|
||||
function sanitiseArgs(args) { |
|
||||
let sanitised = [] |
|
||||
for (let arg of args) { |
|
||||
sanitised.push(arg.replace(regex, "")) |
|
||||
} |
|
||||
return sanitised |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Exactly the same as path.join but creates a sanitised path. |
|
||||
* @param args Any number of string arguments to add to a path |
|
||||
* @returns {string} The final path ready to use |
|
||||
*/ |
|
||||
exports.join = function(...args) { |
|
||||
return path.join(...sanitiseArgs(args)) |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Exactly the same as path.resolve but creates a sanitised path. |
|
||||
* @param args Any number of string arguments to add to a path |
|
||||
* @returns {string} The final path ready to use |
|
||||
*/ |
|
||||
exports.resolve = function(...args) { |
|
||||
return path.resolve(...sanitiseArgs(args)) |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Sanitise a single string |
|
||||
* @param string input string to sanitise |
|
||||
* @returns {string} the final sanitised string |
|
||||
*/ |
|
||||
exports.sanitise = function(string) { |
|
||||
return sanitiseArgs([string])[0] |
|
||||
} |
|
||||
Loading…
Reference in new issue