From 65fe16ad260936cba82fa1f1a454a1d6216e5bf4 Mon Sep 17 00:00:00 2001 From: Filipe Freire Date: Fri, 13 Dec 2024 12:07:46 +0000 Subject: [PATCH 1/3] fix: file paths fail on Windows [INS-4742] --- packages/insomnia/src/templating/utils.ts | 4 ++++ .../src/ui/components/templating/tag-editor.tsx | 15 ++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/insomnia/src/templating/utils.ts b/packages/insomnia/src/templating/utils.ts index d5deb6bae82..9258d1aa41e 100644 --- a/packages/insomnia/src/templating/utils.ts +++ b/packages/insomnia/src/templating/utils.ts @@ -327,3 +327,7 @@ export interface nunjucksTagContextMenuOptions extends Exclude = props => { // Fix strings: arg.value expects an escaped value (based on updateArg logic) for (const arg of activeTagData.args) { if (typeof arg.value === 'string') { - arg.value = arg.value.replace(/\\/g, '\\\\'); + arg.value = sanitizeStrForWin32(arg.value); } } await Promise.all([ @@ -137,7 +138,7 @@ export const TagEditor: FC = props => { } // Fix strings if (typeof argValue === 'string') { - argValue = argValue.replace(/\\/g, '\\\\'); + argValue = sanitizeStrForWin32(argValue); } // Ensure all arguments exist const defaultArgs = templateUtils.tokenizeTag(templateUtils.getDefaultFill( @@ -342,7 +343,7 @@ export const TagEditor: FC = props => { const encoding = argDefinition.encoding || 'utf8'; argInput = ( = props => { showFileName className="btn btn--clicky btn--super-compact" onChange={path => updateArg(path, index)} - path={strValue.replace(/\\\\/g, '\\')} + path={sanitizeStrForWin32(strValue)} itemtypes={argDefinition.itemTypes} extensions={argDefinition.extensions} />); From e1b02a021342d9d430390f4bb8ac5fe2301332f8 Mon Sep 17 00:00:00 2001 From: Filipe Freire Date: Fri, 13 Dec 2024 12:14:01 +0000 Subject: [PATCH 2/3] lint --- packages/insomnia/src/ui/components/templating/tag-editor.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/insomnia/src/ui/components/templating/tag-editor.tsx b/packages/insomnia/src/ui/components/templating/tag-editor.tsx index 562be90a797..cf9896f787b 100644 --- a/packages/insomnia/src/ui/components/templating/tag-editor.tsx +++ b/packages/insomnia/src/ui/components/templating/tag-editor.tsx @@ -17,9 +17,9 @@ import * as plugins from '../../../plugins'; import * as pluginContexts from '../../../plugins/context'; import * as templating from '../../../templating'; import { - sanitizeStrForWin32, type NunjucksParsedTag, type NunjucksParsedTagArg, + sanitizeStrForWin32, } from '../../../templating/utils'; import * as templateUtils from '../../../templating/utils'; import { useNunjucks } from '../../context/nunjucks/use-nunjucks'; From e0e61a4a0766c7b6299bc83cf979695eb0794364 Mon Sep 17 00:00:00 2001 From: Filipe Freire Date: Fri, 13 Dec 2024 12:25:05 +0000 Subject: [PATCH 3/3] Update utils.ts --- packages/insomnia/src/templating/utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/insomnia/src/templating/utils.ts b/packages/insomnia/src/templating/utils.ts index 9258d1aa41e..b6a06ef878e 100644 --- a/packages/insomnia/src/templating/utils.ts +++ b/packages/insomnia/src/templating/utils.ts @@ -328,6 +328,6 @@ export interface nunjucksTagContextMenuOptions extends Exclude