forked from postmanlabs/httpsnippet-fsless
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell.js
More file actions
25 lines (20 loc) · 607 Bytes
/
Copy pathshell.js
File metadata and controls
25 lines (20 loc) · 607 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
'use strict'
var util = require('util')
module.exports = {
/**
* Use 'strong quoting' using single quotes so that we only need
* to deal with nested single quote characters.
* http://wiki.bash-hackers.org/syntax/quoting#strong_quoting
*/
quote: function (value) {
var safe = /^[a-z0-9-_/.@%^=:]+$/i
// Unless `value` is a simple shell-safe string, quote it.
if (!safe.test(value)) {
return util.format('\'%s\'', value.replace(/'/g, "\'\\'\'"))
}
return value
},
escape: function (value) {
return value.replace(/\r/g, '\\r').replace(/\n/g, '\\n')
}
}