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

Unified Diff: utils/dartdoc/files.dart

Issue 8958017: Don't fix up paths that are already absolute. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years 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 | « no previous file | utils/dartdoc/test/dartdoc_tests.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/dartdoc/files.dart
diff --git a/utils/dartdoc/files.dart b/utils/dartdoc/files.dart
index b63fa718d27973083ca2b3615d7901c214f3e57b..53a463e37d68402ec5e9fc2953dfbd9954a91d91 100644
--- a/utils/dartdoc/files.dart
+++ b/utils/dartdoc/files.dart
@@ -37,13 +37,23 @@ endFile() {
}
/**
- * Converts [absolute] which is understood to be a full path from the root of
+ * Converts [fullPath] which is understood to be a full path from the root of
* the generated docs to one relative to the current file.
*/
-String relativePath(String absolute) {
+String relativePath(String fullPath) {
+ // Don't make it relative if it's an absolute path.
+ if (isAbsolute(fullPath)) return fullPath;
+
// TODO(rnystrom): Walks all the way up to root each time. Shouldn't do this
// if the paths overlap.
- return repeat('../', countOccurrences(_filePath, '/')) + absolute;
+ return repeat('../', countOccurrences(_filePath, '/')) + fullPath;
+}
+
+/** Gets whether or not the given URL is absolute or relative. */
+bool isAbsolute(String url) {
+ // TODO(rnystrom): This is a bit hackish. We consider any URL that lacks
+ // a scheme to be relative.
+ return const RegExp(@'^\w+:').hasMatch(url);
}
/** Gets the URL to the documentation for [library]. */
« no previous file with comments | « no previous file | utils/dartdoc/test/dartdoc_tests.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698