Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side 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, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // TODO(nweiz): Avoid importing dart:io directly when cross-platform libraries 5 // TODO(nweiz): Avoid importing dart:io directly when cross-platform libraries
6 // exist. 6 // exist.
7 import 'dart:io'; 7 import 'dart:io';
8 import 'dart:isolate'; 8 import 'dart:isolate';
9 import 'dart:async'; 9 import 'dart:async';
10 import 'dart:convert'; 10 import 'dart:convert';
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 if (uri is Uri) return uri; 70 if (uri is Uri) return uri;
71 if (uri is String) return Uri.parse(uri); 71 if (uri is String) return Uri.parse(uri);
72 72
73 throw new ArgumentError.value(uri, name, "Must be a String or a Uri."); 73 throw new ArgumentError.value(uri, name, "Must be a String or a Uri.");
74 } 74 }
75 75
76 /// Returns a copy of [uri] with a trailing slash. 76 /// Returns a copy of [uri] with a trailing slash.
77 /// 77 ///
78 /// If [uri] already ends in a slash, returns it as-is. 78 /// If [uri] already ends in a slash, returns it as-is.
79 Uri ensureTrailingSlash(Uri uri) { 79 Uri ensureTrailingSlash(Uri uri) {
80 if (uri.pathSegments.isEmpty) return uri.replace(path: "/");
80 if (uri.pathSegments.last.isEmpty) return uri; 81 if (uri.pathSegments.last.isEmpty) return uri;
81 return uri.replace(pathSegments: uri.pathSegments.toList()..add("")); 82 return uri.replace(pathSegments: uri.pathSegments.toList()..add(""));
82 } 83 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698