Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Plugins / Tags] Method disablePreview recieve escaped path for argument of type 'file' #7177

Open
1 task done
iRomul opened this issue Mar 13, 2024 · 0 comments
Open
1 task done
Labels
B-bug Bug: general classification S-unverified Status: Unverified by maintainer

Comments

@iRomul
Copy link

iRomul commented Mar 13, 2024

Expected Behavior

module.exports.templateTags = [
    {
        disablePreview(args) {
            console.log(args[0]); // <--------
            // Expected
            // > obj {type: 'string', value: 'C:\Users\Roman.Komarevtsev\test.json', quotedBy: "'"}
            return false;
        },
        args: [
            {
                displayName: 'Filename 1',
                type: 'file'
            }
        ],
        async run(_context, arg1) {
            console.log(arg1);
            // out: string 'C:\Users\Roman.Komarevtsev\test.json'
        }
    }
]

Actual Behavior

module.exports.templateTags = [
    {
        disablePreview(args) {
            console.log(args[0]); // <--------
            // Actual
            // > obj {type: 'string', value: 'C:UsersRoman.Komarevtsevtest.json', quotedBy: "'"}
            return false;
        },
        args: [
            {
                displayName: 'Filename 1',
                type: 'file'
            }
        ],
        async run(_context, arg1) {
            console.log(arg1);
            // out: string 'C:\Users\Roman.Komarevtsev\test.json'
        }
    }
]

Reproduction Steps

No response

Is there an existing issue for this?

Additional Information

When I'm writing new plugin with a custom tag, I ran into a problem that a argument of type 'file' passed as a parameter of disablePreview(args) (also affects liveDisplayName) contains escaped Windows path (all file separators are trimmed).
Example:
Real path: C:\Users\Roman.Komarevtsev\test.json
Passed value (args[0].value): C:UsersRoman.Komarevtsevtest.json
Meanwhile, async run(context, ...args) receive a correct path, which can be consumed by fs.readFileSync(...).

I'd like to get a real path in a disablePreview or liveDisplayName because for my tag logic I need to construct well-formed instance of URL.

Full example available here: https://gist.github.com/iRomul/06a2080e4dd8c0f2dd7b8a4a6e67c871

Insomnia Version

8.6.1

What operating system are you using?

Windows

Operating System Version

Windows 10 Enterprise LTSC 21H2 19044.3930

Installation method

Windows installer from insomnia.rest

Last Known Working Insomnia version

No response

@iRomul iRomul added B-bug Bug: general classification S-unverified Status: Unverified by maintainer labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-bug Bug: general classification S-unverified Status: Unverified by maintainer
Projects
None yet
Development

No branches or pull requests

1 participant