fix(editor): Fix completions for .json on quoted node name in Code node (#7382)

To reproduce, request completion with `$input.first().json.` from a node
with a quote in the name, e.g. `When clicking "Execute Workflow"`.

Context:
https://linear.app/n8n/issue/PAY-635/autocomplete-only-supports-3-levels-of-children#comment-234f738b
This commit is contained in:
Iván Ovejero 2023-10-10 10:05:41 +02:00 committed by GitHub
parent fbcd1d40ed
commit 86e7ec796a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -275,7 +275,16 @@ export const jsonFieldCompletions = defineComponent({
* `index` is only passed for `all()`.
*/
getJsonOutput(quotedNodeName: string, options?: { accessor?: string; index?: number }) {
const nodeName = quotedNodeName.replace(/['"]/g, '');
let nodeName = quotedNodeName;
const isSingleQuoteWrapped = quotedNodeName.startsWith("'") && quotedNodeName.endsWith("'");
const isDoubleQuoteWrapped = quotedNodeName.startsWith('"') && quotedNodeName.endsWith('"');
if (isSingleQuoteWrapped) {
nodeName = quotedNodeName.replace(/^'/, '').replace(/'$/, '');
} else if (isDoubleQuoteWrapped) {
nodeName = quotedNodeName.replace(/^"/, '').replace(/"$/, '');
}
const pinData: IPinData | undefined = this.workflowsStore.getPinData;