mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-12-18 18:04:28 +08:00
优化转义规则
This commit is contained in:
@@ -2,17 +2,11 @@
|
||||
* 所有的特殊变量
|
||||
*/
|
||||
|
||||
let escapeItem = item => {
|
||||
if (typeof item === 'number') return item
|
||||
item = typeof item === 'object' ? JSON.stringify(item) : item.replace(/\\/g, '\\\\')
|
||||
return item.replace('$', '$$$')
|
||||
}
|
||||
|
||||
let handlingJsonVar = (jsonVar, name, payload) => {
|
||||
try {
|
||||
return escapeItem(window.evalCodeInSandbox(jsonVar.slice(2, -2), {
|
||||
return window.evalCodeInSandbox(jsonVar.slice(2, -2), {
|
||||
[name]: payload
|
||||
}))
|
||||
})
|
||||
} catch (e) {
|
||||
return utools.showNotification(e)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user