Kong / insomnia

The open-source, cross-platform API client for GraphQL, REST, WebSockets, SSE and gRPC. With Cloud, Local and Git storage.
https://insomnia.rest
Apache License 2.0
33.72k stars 1.88k forks source link

Insomnia plugin always adding a ';' at the end of the string when used in the Headers section #4442

Open ziyaaktas opened 2 years ago

ziyaaktas commented 2 years ago

Expected Behavior

Insomnia plugin should return the string as is

Actual Behavior

When i look at the timeline of the request, I see there is a ';' character added at the end.

Reproduction Steps

Install https://github.com/mageshwaranr/insomnia-plugin-sh-cmd plugin use "execute a command" option in the bulk edit headers make a request

Is there an existing issue for this?

Additional Information

The plugin is quite simple actually

const { promisify } = require('util');
const exec = promisify(require('child_process').exec)

module.exports.templateTags = [
  {
    displayName: "/bin/sh",
    name: "shCmdExec",
    description:
      "Executes given command using child_process package, basically /bin/sh cmd",
    args: [
      {
        displayName: "Type",
        type: "enum",
        options: [
          {
            displayName: "Execute command returning String value",
            value: "string",
          },
          {
            displayName: "Execute command returning JSON value",
            value: "json",
          },
        ],
      },
      {
        displayName: "Command/shell to be executed",
        help: 'Executes the given command using require("child_process").exec command',
        type: "string",
      },
    ],
    async run(context, type = "string", cmd) {
      try {
        var resp = await exec(cmd)
      } catch (failed) {
        console.log("Command execution failed with " + failed)
        return failed.stderr
      }

      if (type == "json") {
        return JSON.parse(resp.stdout.trim()) // add test case
      }
      return resp.stdout.trim()
    },
  },
]

If I copy/paste the values from the live preview field, it works, but not as a variable.

Insomnia Version

2021.7.2

What operating system are you using?

macOS

Operating System Version

Macos Big Sur 11.6.3

Installation method

homebrew

Last Known Working Insomnia version

No response

ziyaaktas commented 2 years ago

bump