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

Unified Diff: lib/src/context.dart

Issue 937683002: Don't use 'current' if 'from' is not relative. (Closed) Base URL: https://github.com/dart-lang/path@master
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« 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/context.dart
diff --git a/lib/src/context.dart b/lib/src/context.dart
index a3efd95a9cbd4c4b5829df32149857911d4f1028..7a210c60d92769acc5bd242cbeceb653b07d5794 100644
--- a/lib/src/context.dart
+++ b/lib/src/context.dart
@@ -324,7 +324,11 @@ class Context {
/// "/", no path can be determined. In this case, a [PathException] will be
/// thrown.
String relative(String path, {String from}) {
- from = from == null ? current : this.join(current, from);
+ if (from == null) {
+ from = current;
+ } else if (this.isRelative(from) || this.isRootRelative(from)) {
Bob Nystrom 2015/02/18 17:09:08 Document this: // Avoid calling [current] since i
+ from = this.join(current, from);
+ }
// We can't determine the path from a relative path to an absolute path.
if (this.isRelative(from) && this.isAbsolute(path)) {
« 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