MCPcopy Create free account
hub / github.com/Script-Hub-Org/Script-Hub / unwrapJsonArgument

Function unwrapJsonArgument

Rewrite-Parser.beta.js:2136–2143  ·  view source on GitHub ↗
(str, targetApp = 'loon-plugin')

Source from the content-addressed store, hash-verified

2134}
2135
2136function unwrapJsonArgument(str, targetApp = 'loon-plugin') {
2137 let value = normalizeTemplateValue(str, targetApp)
2138 value = stripWrapQuote(value).trim()
2139 const unescaped = value.replace(/\\"/g, '"').replace(/\\'/g, "'").replace(/\\\\/g, '\\').trim()
2140 if (/^\s*\{[\s\S]*\}\s*$/.test(unescaped) && /:/.test(unescaped)) return unescaped
2141 if (/^\s*\{[\s\S]*\}\s*$/.test(value) && /:/.test(value)) return value
2142 return /^\s*\{[\s\S]*\}\s*$/.test(unescaped) && /:/.test(unescaped) ? unescaped : ''
2143}
2144
2145function isJsonObjectArgument(str) {
2146 return !!unwrapJsonArgument(str)

Callers 2

isJsonObjectArgumentFunction · 0.85
formatLoonJsonArgumentFunction · 0.85

Calls 2

normalizeTemplateValueFunction · 0.85
stripWrapQuoteFunction · 0.85

Tested by

no test coverage detected