Skip to content

Commit

Permalink
refactored the chunker regex into a string
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed May 13, 2013
1 parent 2adb373 commit 0331c7f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,16 @@ exports.quote = function (xs) {
}).join(' ');
};

var CONTROL = '(?:\\|\\||\\&\\&|;;|\\|\\&[&;()|])';
var META = '[|&;()<> \\t]';

exports.parse = function parse (s, env) {
var chunker = /(['"])((\\\1|[^\1])*?)\1|(\\[ \t&|]|[^\s&|])+|([&|])/g;
var chunker = new RegExp(
'([\'"])((\\\\\\1|[^\\1])*?)\\1'
+ '|(\\\\[|&;()<> \\t]|[^\\s&|])+'
+ '|([&|])',
'g'
);
var match = s.match(chunker);
if (!match) return [];
if (!env) env = {};
Expand Down

0 comments on commit 0331c7f

Please sign in to comment.