Only escape minimal characters and allow HTML escapes
This commit is contained in:
parent
195411fe8d
commit
80f16a4aaf
1 changed files with 14 additions and 3 deletions
|
@ -30,11 +30,22 @@ class common extends utils {
|
||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
|
|
||||||
static quote (s) {
|
/**
|
||||||
|
* Escape and quote a string
|
||||||
|
* @param s {string} - String to be quoted
|
||||||
|
* @param html {boolean} - Identifies whether the string must be HTML safe
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
static quote (s, html = false) {
|
||||||
|
const options = {
|
||||||
|
minimal: true,
|
||||||
|
isScriptContext: html
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof s === 'string') {
|
if (typeof s === 'string') {
|
||||||
return `'${jsesc(s)}'`
|
return `'${jsesc(s, options)}'`
|
||||||
} else {
|
} else {
|
||||||
return jsesc(s)
|
return jsesc(s, options)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue