Skip to content

Commit 21681ab

Browse files
authored
Parsing commands with question mark fails (fixes #9) (#10)
Co-authored-by: Jan Stastny
1 parent 7f10567 commit 21681ab

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "docker-file-parser",
3-
"version": "1.0.4",
3+
"version": "1.0.5",
44
"description": "Parses a Dockerfile and returns an array of commands.",
55
"keywords": [
66
"dockerfile",

parser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ function parse(contents, options) {
369369
var i;
370370
var line;
371371
var lineno;
372-
var lines = contents.split(/[\r?\n]/);
372+
var lines = contents.split(/\r?\n/);
373373
var lookingForDirectives = true;
374374
var parseOptions = {};
375375
var parseResult;

test/test_parser.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,19 @@ tape('escape parser directive', function (t) {
167167

168168
t.end();
169169
});
170+
171+
172+
tape('correctly parses commands with question mark', function (t) {
173+
var lines = [
174+
'FROM cirrusci/wget',
175+
'',
176+
'RUN wget http://google.com?hello=world'
177+
];
178+
var dockerFile = lines.join('\n');
179+
180+
var commands = dockerfileParser.parse(dockerFile);
181+
t.equal(commands.length, 2);
182+
t.deepEqual(commands[1].args, 'wget http://google.com?hello=world');
183+
184+
t.end();
185+
});

0 commit comments

Comments
 (0)