[Plugins / Tags] Method disablePreview recieve escaped path for argument of type 'file'
- Dominant language
- TypeScript
- Stars
- 40k
- Forks
- 2.4k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 61
Description
### Expected Behavior
```js
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
```js
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?
- [X] I have searched the [issue tracker](https://www.github.com/Kong/insomnia/issues) for this problem.
### 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_
Contributor guide
Research direction
Start at the custom-tag argument handling used by disablePreview(args) and liveDisplayName, then compare it with the path passed to async run(context, ...args). Verify the Windows file path remains intact in args[0].value while preserving the existing run behavior; the result should support constructing a URL from the preview callback argument.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100