Skip to content

Commit

Permalink
fix(editor): Fix completions for .json on quoted node name in Code …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
ivov committed Oct 10, 2023
1 parent fbcd1d4 commit 86e7ec7
Showing 1 changed file with 10 additions and 1 deletion.
Expand Up @@ -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;

Expand Down

0 comments on commit 86e7ec7

Please sign in to comment.