Normalize paths in DartUri (#515)
* Normalize paths
diff --git a/dwds/CHANGELOG.md b/dwds/CHANGELOG.md
index 0ca1e9b..6d8d15e 100644
--- a/dwds/CHANGELOG.md
+++ b/dwds/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.4.1
+
+- Fix an issue where we source map paths were not normalized.
+
## 0.4.0
- Move `data` abstractions from `package:webdev` into `package:dwds`.
diff --git a/dwds/lib/src/utilities/dart_uri.dart b/dwds/lib/src/utilities/dart_uri.dart
index 93405a7..98f8248 100644
--- a/dwds/lib/src/utilities/dart_uri.dart
+++ b/dwds/lib/src/utilities/dart_uri.dart
@@ -45,7 +45,7 @@
if (serverUri != null) {
var path = Uri.parse(serverUri).path;
var dir = p.dirname(path);
- return DartUri._fromServerPath(p.join(dir, uri));
+ return DartUri._fromServerPath(p.normalize(p.join(dir, uri)));
}
throw FormatException('Unsupported URI form', uri);
}
diff --git a/dwds/pubspec.yaml b/dwds/pubspec.yaml
index a5d30c6..448d4f6 100644
--- a/dwds/pubspec.yaml
+++ b/dwds/pubspec.yaml
@@ -1,5 +1,5 @@
name: dwds
-version: 0.4.0
+version: 0.4.1-dev
author: Dart Team <misc@dartlang.org>
homepage: https://github.com/dart-lang/webdev/tree/master/dwds
description: >-
diff --git a/dwds/test/dart_ui_test.dart b/dwds/test/dart_ui_test.dart
new file mode 100644
index 0000000..439bd7f
--- /dev/null
+++ b/dwds/test/dart_ui_test.dart
@@ -0,0 +1,35 @@
+// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:dwds/src/utilities/dart_uri.dart';
+import 'package:test/test.dart';
+
+void main() {
+ group('DartUri', () {
+ test('normalizes server paths', () {
+ var uri = DartUri('../foo.dart', '/packages/blah/src/blah.dart');
+ expect(uri.serverPath, 'packages/blah/foo.dart');
+ });
+
+ test('parses package : paths', () {
+ var uri = DartUri('package:path/path.dart');
+ expect(uri.serverPath, 'packages/path/path.dart');
+ });
+
+ test('parses org-dartlang-app paths', () {
+ var uri = DartUri('org-dartlang-app:////blah/main.dart');
+ expect(uri.serverPath, 'blah/main.dart');
+ });
+
+ test('parses packages paths', () {
+ var uri = DartUri('/packages/blah/foo.dart');
+ expect(uri.serverPath, 'packages/blah/foo.dart');
+ });
+
+ test('parses http paths', () {
+ var uri = DartUri('http://localhost:8080/web/main.dart');
+ expect(uri.serverPath, 'web/main.dart');
+ });
+ });
+}
diff --git a/webdev/pubspec.yaml b/webdev/pubspec.yaml
index a8ee01f..91331ea 100644
--- a/webdev/pubspec.yaml
+++ b/webdev/pubspec.yaml
@@ -47,3 +47,7 @@
executables:
webdev:
+
+dependency_overrides:
+ dwds:
+ path: ../dwds