bongosway / insomnia-plugin-dotenv

insomnia-dotenv is an open-source plugin for the https://insomnia.rest/ that helps users avoid having/exporting sensitive data in plain-text in the “Manage Environments” section of Insomnia.
13 stars 4 forks source link

File path slashes not working in Windows #16

Open randoogle opened 1 year ago

randoogle commented 1 year ago

Describe the bug When in Windows, the resulting file path in the Edit Variable preview is missing all folder slashes in Windows. Example: "C:\Users\someuser\secret_file.env" becomes "C:Userssomeusersecret_file.env" This causes an error: "ENOENT: no such file or directory, open 'C:Userssomeusersecret_file.env'"

To Reproduce Steps to reproduce the behavior:

  1. Add environment variable in Base Environment
  2. Tie variable to dotenv file
  3. Note that it outputs the correct value from dotenv file when in Manage Environments
  4. Close Manage Environments
  5. Attempt to use variable in a request (it doesn't seem to matter where)
  6. See the error in preview "ENOENT: no such file or directory, open [file location without slashes]"

Expected behavior I would expect the Edit Variable to pull in the value of the variable with no error.

Screenshots image image

Desktop (please complete the following information):

Additional context I notice that the error is different if you use a dotenv in a Sub Environment. It doesn't bother to output the file path at all. Also, I've tried the same project and same file in Linux, and this plugin works fine.

sturose commented 1 year ago

I can confirm, this has impacted me as well on Windows.

pfefferf commented 1 year ago

Seems that this repo is not maintained anymore.

I have created a fork of this plugin and fixed the issue in the plugin. Unfortunately, it seems that Insomnia has a general issue with escaping. So I changed the type of the .env file parameter to a string, to be able to enter an adapted path with an own escape sequence. For Windows instead of backslashses forward slashes must be used. And these forward slashes must be escaped with a backslash.

Forked plugin: https://www.npmjs.com/package/insomnia-plugin-fpf-dotenv (installation via npm package insomnia-plugin-fpf-dotenv).