From 61fab44b04e3f746933b7eaf8d9303bf4ac716c9 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Fri, 30 Jun 2017 09:00:00 -0700 Subject: [PATCH] Fix unix domain socket match --- app/network/__tests__/network.test.js | 34 +++++++++++++++++++++++++++ app/network/network.js | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/app/network/__tests__/network.test.js b/app/network/__tests__/network.test.js index 58a02e572..3fba3a666 100644 --- a/app/network/__tests__/network.test.js +++ b/app/network/__tests__/network.test.js @@ -367,4 +367,38 @@ describe('actuallySend()', () => { } }); }); + + it('uses works with "unix" host', async () => { + const workspace = await models.workspace.create(); + const settings = await models.settings.create(); + + const request = Object.assign(models.request.init(), { + _id: 'req_123', + parentId: workspace._id, + url: 'http://unix:3000/my/path', + method: 'GET' + }); + + const renderedRequest = await getRenderedRequest(request); + const {bodyBuffer} = await networkUtils._actuallySend(renderedRequest, workspace, settings); + // console.log('HELLO', response); + + const body = JSON.parse(bodyBuffer); + expect(body).toEqual({ + options: { + CUSTOMREQUEST: 'GET', + ACCEPT_ENCODING: '', + COOKIEFILE: '', + FOLLOWLOCATION: true, + HTTPHEADER: ['content-type: '], + NOPROGRESS: false, + PROXY: '', + NOBODY: 0, + TIMEOUT_MS: 0, + URL: 'http://unix:3000/my/path', + USERAGENT: `insomnia/${getAppVersion()}`, + VERBOSE: true + } + }); + }); }); diff --git a/app/network/network.js b/app/network/network.js index 1d100d526..8f7cfa252 100644 --- a/app/network/network.js +++ b/app/network/network.js @@ -162,7 +162,7 @@ export function _actuallySend (renderedRequest, workspace, settings) { // Set the URL, including the query parameters const qs = querystring.buildFromParams(renderedRequest.parameters); const url = querystring.joinUrl(renderedRequest.url, qs); - const isUnixSocket = url.match(/https?:\/\/unix:/); + const isUnixSocket = url.match(/https?:\/\/unix:\//); const finalUrl = util.prepareUrlForSending(url, renderedRequest.settingEncodeUrl); if (isUnixSocket) { // URL prep will convert "unix:/path" hostname to "unix/path"