refactor: Create net-request-promise helper for runtimesettin
This commit is contained in:
5 files changed
+18
-9
No files matched your search
+9
-1
@@ -1,9 +1,11 @@
|
||||
const { quote } = require('shell-quote');
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* Super paranoid shell quote/escape and validation. Input must be base62.
|
||||
* @param {string} str
|
||||
*/
|
||||
escapeAndValidate: (str) => {
|
||||
base62EscapeAndValidate: (str) => {
|
||||
const candidate = str.toString();
|
||||
if (candidate.match(/^[A-Za-z0-9_]*$/)) return candidate;
|
||||
throw new Error(`
|
||||
@@ -11,4 +13,10 @@ module.exports = {
|
||||
input contained unsafe characters.
|
||||
`);
|
||||
},
|
||||
/**
|
||||
* Return a quoted string suitable for using in shell commands.
|
||||
* @param {string} str
|
||||
* @returns {string}
|
||||
*/
|
||||
shellEscape: (str) => quote([str]),
|
||||
};
|
||||
Reference in new issue
Block a user