@neo4j-cypher/editor-support
Version:
Core functionality to support Cypher integration into editors
15 lines (14 loc) • 430 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ecsapeCypher = void 0;
const ecsapeCypher = str => {
const prefix = str.startsWith(":") ? ":" : "";
let content = str;
if (prefix.length > 0) {
content = str.substring(1);
}
return /^[A-Za-z][A-Za-z0-9_]*$/.test(content) ? prefix + content : `${prefix}\`${content.replace(/`/g, "``")}\``;
};
exports.ecsapeCypher = ecsapeCypher;