From bd2755a302fea417eb124fe1995d5ed709b53cd4 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 28 Jan 2019 11:27:36 +0100 Subject: [PATCH] Updated test --- test/unit/connection.test.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/unit/connection.test.js b/test/unit/connection.test.js index 98a3fe940..b2e8d92d6 100644 --- a/test/unit/connection.test.js +++ b/test/unit/connection.test.js @@ -573,3 +573,21 @@ test('Should throw if the protocol is not http or https', t => { } t.end() }) + +// https://github.com/nodejs/node/commit/b961d9fd83 +test('Should disallow two-byte characters in URL path', t => { + t.plan(1) + + const connection = new Connection({ + url: new URL('http://localhost:9200') + }) + connection.request({ + path: '/thisisinvalid' + encodeURIComponent('\uffe2'), + method: 'GET' + }, (err, res) => { + t.strictEqual( + err.message, + 'ERR_UNESCAPED_CHARACTERS: /thisisinvalid\uffe2' + ) + }) +})