Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/src/parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ class Parser {
var stripped = strip(line);
if (!_isValid(stripped)) return {};

var sides = stripped.split('=');
var lhs = sides[0];
var idx = stripped.indexOf('=');
var lhs = stripped.substring(0, idx);
var k = swallow(lhs);
if (k.isEmpty) return {};

var rhs = sides[1].trim();
var rhs = stripped.substring(idx + 1, stripped.length).trim();
var quotChar = surroundingQuote(rhs);
var v = unquote(rhs);

Expand Down
11 changes: 11 additions & 0 deletions test/parser_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ void main() {
subj.interpolate_fallback);
test('it handles \${surrounding braces} on vars', subj.interpolate_curlies);

test('it handles equal signs in values', subj.parseOne_equals);
test('it knows quoted # is not a comment', subj.parseOne_pound);
test('it handles quotes in a comment',
subj.parseOne_commentQuote_terminalChar);
Expand Down Expand Up @@ -77,6 +78,16 @@ class ParserTest {
expect(single['foo'], equals('ab#c'));
}

void parseOne_equals() {
var none = _psr.parseOne('foo=bar=qux');
var sing = _psr.parseOne("foo='bar=qux'");
var doub = _psr.parseOne('foo="bar=qux"');

expect(none['foo'], equals('bar=qux'));
expect(sing['foo'], equals('bar=qux'));
expect(doub['foo'], equals('bar=qux'));
}

void interpolate() {
var out = _psr.interpolate(r'a$foo$baz', {'foo': 'bar', 'baz': 'qux'});
expect(out, equals('abarqux'));
Expand Down