diff --git a/lib/src/parser.dart b/lib/src/parser.dart index bc203fb..40c44fb 100644 --- a/lib/src/parser.dart +++ b/lib/src/parser.dart @@ -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); diff --git a/test/parser_test.dart b/test/parser_test.dart index d1aeb79..2d4fdd8 100644 --- a/test/parser_test.dart +++ b/test/parser_test.dart @@ -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); @@ -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'));