From bc09d2f83d1fd980afbe18f5749228149fa04248 Mon Sep 17 00:00:00 2001 From: himself65 Date: Sat, 9 Mar 2019 22:39:53 +0800 Subject: [PATCH] src: fix SplitString to ignore white spaces PR-URL: https://github.com/nodejs/node/pull/26545 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Richard Lau Reviewed-By: Khaidi Chu --- src/util.cc | 1 + test/parallel/test-cli-node-options.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/util.cc b/src/util.cc index f070401934f78b..d41163500344ca 100644 --- a/src/util.cc +++ b/src/util.cc @@ -134,6 +134,7 @@ std::vector SplitString(const std::string& in, char delim) { while (in_stream.good()) { std::string item; std::getline(in_stream, item, delim); + if (item.empty()) continue; out.emplace_back(std::move(item)); } return out; diff --git a/test/parallel/test-cli-node-options.js b/test/parallel/test-cli-node-options.js index 7f6524c09a8c81..5fd6c1f2c9c17c 100644 --- a/test/parallel/test-cli-node-options.js +++ b/test/parallel/test-cli-node-options.js @@ -14,6 +14,8 @@ tmpdir.refresh(); const printA = require.resolve('../fixtures/printA.js'); expect(`-r ${printA}`, 'A\nB\n'); expect(`-r ${printA} -r ${printA}`, 'A\nB\n'); +expect(` -r ${printA} -r ${printA}`, 'A\nB\n'); +expect(` --require ${printA} --require ${printA}`, 'A\nB\n'); expect('--no-deprecation', 'B\n'); expect('--no-warnings', 'B\n'); expect('--no_warnings', 'B\n');