Make the stack_trace package print relative URLs for browser paths. Prior to this, only console paths were printed as relative. R=rnystrom@google.com BUG= Review URL: https://codereview.chromium.org//75543013 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/stack_trace@30484 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/pkgs/stack_trace/lib/src/frame.dart b/pkgs/stack_trace/lib/src/frame.dart index 6a88a26..74aafcd 100644 --- a/pkgs/stack_trace/lib/src/frame.dart +++ b/pkgs/stack_trace/lib/src/frame.dart
@@ -69,7 +69,8 @@ /// This will usually be the string form of [uri], but a relative URI will be /// used if possible. String get library { - if (uri.scheme != 'file') return uri.toString(); + if (uri.scheme != Uri.base.scheme) return uri.toString(); + if (path.style == path.Style.url) return path.relative(uri.toString()); return path.relative(path.fromUri(uri)); }
diff --git a/pkgs/stack_trace/pubspec.yaml b/pkgs/stack_trace/pubspec.yaml index 63a1bf9..c71a781 100644 --- a/pkgs/stack_trace/pubspec.yaml +++ b/pkgs/stack_trace/pubspec.yaml
@@ -6,7 +6,7 @@ A package for manipulating stack traces and printing them readably. dependencies: - path: ">=0.9.0 <0.10.0" + path: ">=1.0.0-rc.1 <2.0.0" dev_dependencies: unittest: ">=0.9.0 <0.10.0"
diff --git a/pkgs/stack_trace/test/frame_test.dart b/pkgs/stack_trace/test/frame_test.dart index bd09ed8..9722d38 100644 --- a/pkgs/stack_trace/test/frame_test.dart +++ b/pkgs/stack_trace/test/frame_test.dart
@@ -495,5 +495,11 @@ expect(new Frame.parseVM('#0 Foo (dart:core/uri.dart:5)').toString(), equals('dart:core/uri.dart 5 in Foo')); }); + + test('prints relative paths as relative', () { + var relative = path.normalize('relative/path/to/foo.dart'); + expect(new Frame.parseFriendly('$relative 5:10 Foo').toString(), + equals('$relative 5:10 in Foo')); + }); }); }