Skip to content

Commit

Permalink
Fix parsing for URIs with a : in the authority (flutter#69)
Browse files Browse the repository at this point in the history
Add a `$` to enforce that the `:(\d+)` is at the end of the String. The
previous regex could pick up too little - we end up with
`http://localhost` as the URI and the port as the line.

Switch from `pub.dartlang.org` to `example.com` to avoid references
to legacy URLs.
  • Loading branch information
natebosch authored Apr 30, 2020
1 parent 40ef972 commit 0756983
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/src/frame.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ final _v8Frame =
RegExp(r'^\s*at (?:(\S.*?)(?: \[as [^\]]+\])? \((.*)\)|(.*))$');

// https://example.com/stuff.dart.js:560:28
// http://pub.dartlang.org/stuff.dart.js:560
final _v8UrlLocation = RegExp(r'^(.*?):(\d+)(?::(\d+))?|native$');
// https://example.com/stuff.dart.js:560
final _v8UrlLocation = RegExp(r'^(.*?):(\d+)(?::(\d+))?$|native$');

// eval as function (https://example.com/stuff.dart.js:560:28), efn:3:28
// eval as function (https://example.com/stuff.dart.js:560:28)
Expand Down
10 changes: 10 additions & 0 deletions test/frame_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ void main() {
expect(frame.member, equals('VW.call\$0'));
});

test('parses a stack frame with a : in the authority', () {
var frame = Frame.parseV8(' at VW.call\$0 '
'(http://localhost:8080/stuff.dart.js:560:28)');
expect(
frame.uri, equals(Uri.parse('http://localhost:8080/stuff.dart.js')));
expect(frame.line, equals(560));
expect(frame.column, equals(28));
expect(frame.member, equals('VW.call\$0'));
});

test('parses a stack frame with an absolute POSIX path correctly', () {
var frame = Frame.parseV8(' at VW.call\$0 '
'(/path/to/stuff.dart.js:560:28)');
Expand Down

0 comments on commit 0756983

Please sign in to comment.