Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_prettifyXML(code) {
if (this.props.updateFilter && this.state.filter) {
try {
const results = queryXPath(code, this.state.filter);
code = `${results.map(r => r.outer).join('\n')}`;
} catch (err) {
// Failed to parse filter (that's ok)
code = `${err.message}`;
}
}
try {
return vkBeautify.xml(code, this._indentChars());
} catch (e) {
// Failed to parse so just return original
return code;
}
}
function matchXPath(bodyStr, query) {
const results = queryXPath(bodyStr, query);
if (results.length === 0) {
throw new Error(`Returned no results: ${query}`);
} else if (results.length > 1) {
throw new Error(`Returned more than one result: ${query}`);
}
return results[0].inner;
}