diff options
author | himself65 <himself6565@gmail.com> | 2019-03-09 22:39:53 +0800 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2019-03-14 17:15:30 +0100 |
commit | bc09d2f83d1fd980afbe18f5749228149fa04248 (patch) | |
tree | 0e596f2fa42eaa486e1d93dbdbf8db2145c6793b | |
parent | cba23ed92ae0b76b1e233086cc284824453c6997 (diff) | |
download | node-new-bc09d2f83d1fd980afbe18f5749228149fa04248.tar.gz |
src: fix SplitString to ignore white spaces
PR-URL: https://github.com/nodejs/node/pull/26545
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Khaidi Chu <i@2333.moe>
-rw-r--r-- | src/util.cc | 1 | ||||
-rw-r--r-- | test/parallel/test-cli-node-options.js | 2 |
2 files changed, 3 insertions, 0 deletions
diff --git a/src/util.cc b/src/util.cc index f070401934..d411635003 100644 --- a/src/util.cc +++ b/src/util.cc @@ -134,6 +134,7 @@ std::vector<std::string> 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 7f6524c09a..5fd6c1f2c9 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'); |