Chromium Code Reviews

Unified Diff: lib/src/utils.dart

Issue 2268153003: Fix a crash. (Closed) Base URL: git@github.com:dart-lang/package_resolver@master
Patch Set: Code review changes Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/utils.dart
diff --git a/lib/src/utils.dart b/lib/src/utils.dart
index 77de03da613924d682e1ab0eeb4534c991364dc1..e7c605cf0305ff4aea39039f5e8be0400f11425e 100644
--- a/lib/src/utils.dart
+++ b/lib/src/utils.dart
@@ -77,6 +77,7 @@ Uri asUri(uri, String name) {
///
/// If [uri] already ends in a slash, returns it as-is.
Uri ensureTrailingSlash(Uri uri) {
+ if (uri.pathSegments.isEmpty) return uri.replace(path: "/");
if (uri.pathSegments.last.isEmpty) return uri;
return uri.replace(pathSegments: uri.pathSegments.toList()..add(""));
}
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine