fix: change regex lookbehind to group (#29)

fixes runtime errors in safari
This commit is contained in:
ngxingyu
2021-04-28 04:54:12 +08:00
committed by GitHub
parent 6f0fd02c15
commit 106bd1dd58
9 changed files with 59 additions and 54 deletions

View File

@ -1,6 +1,6 @@
FOO=foo
BAR=bar
FOOBAR=\$FOO$BAR
FOOBAR=\$FOO${FOO}$BAR
ESCAPED_DOLLAR_SIGN="\$1000"
ESCAPED_QUOTE='\''

View File

@ -7,13 +7,13 @@ void main() {
setUp(() {
print(Directory.current.toString());
dotenv.testLoad(
fileInput: File('.env')
fileInput: File('test/.env')
.readAsStringSync()); //, mergeWith: Platform.environment
});
test('able to load .env', () {
expect(dotenv.env['FOO'], 'foo');
expect(dotenv.env['BAR'], 'bar');
expect(dotenv.env['FOOBAR'], '\$FOObar');
expect(dotenv.env['FOOBAR'], '\$FOOfoobar');
expect(dotenv.env['ESCAPED_DOLLAR_SIGN'], '\$1000');
expect(dotenv.env['ESCAPED_QUOTE'], "'");
expect(dotenv.env['BASIC'], 'basic');

View File

@ -1,6 +1,6 @@
import 'dart:math';
import 'package:flutter_dotenv/src/parser.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:test/test.dart';
const ceil = 100000;
@ -100,8 +100,8 @@ void main() {
expect(out, equals({'foo': 'bar'}));
});
test('it substitutes known variables into other values', () {
var out = _psr.parse(['foo=bar', r'baz=super$foo']);
expect(out, equals({'foo': 'bar', 'baz': 'superbar'}));
var out = _psr.parse(['foo=bar', r'baz=super$foo${foo}']);
expect(out, equals({'foo': 'bar', 'baz': 'superbarbar'}));
});
test('it discards surrounding quotes', () {
var out = _psr.parse([r"foo = 'bar'", r'export baz="qux"']);