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>
This commit is contained in:
himself65 2019-03-09 22:39:53 +08:00 committed by Daniel Bevenius
parent a4d4e9d721
commit 17ab2ed3c8
2 changed files with 3 additions and 0 deletions

View File

@ -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;

View File

@ -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');