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

Unified Diff: ui/file_manager/file_manager/common/js/util.js

Issue 253343003: Stop appending slash for directory's URL in util.isDescendantEntry() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Append traling slash for ancestor directory when it misses. Created 6 years, 8 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/file_manager/common/js/util.js
diff --git a/ui/file_manager/file_manager/common/js/util.js b/ui/file_manager/file_manager/common/js/util.js
index 7f2ba1d06f86b06fd60b3be5bf33178d3ee26da5..ce8f5fe10bbddbf8314a3a2fac63d12631140638 100644
--- a/ui/file_manager/file_manager/common/js/util.js
+++ b/ui/file_manager/file_manager/common/js/util.js
@@ -1113,15 +1113,19 @@ util.isSameFileSystem = function(fileSystem1, fileSystem2) {
util.isDescendantEntry = function(ancestorEntry, childEntry) {
if (!ancestorEntry.isDirectory)
return false;
-
- // TODO(mtomasz): Do not work on URLs. Instead consider comparing file systems
- // and paths.
+ if (!util.isSameFileSystem(ancestorEntry.filesystem, childEntry.filesystem))
+ return false;
if (util.isSameEntry(ancestorEntry, childEntry))
return false;
- if (childEntry.toURL().indexOf(ancestorEntry.toURL() + '/') !== 0)
+ if (util.isFakeEntry(ancestorEntry) || util.isFakeEntry(childEntry))
return false;
- return true;
+ // Check if the ancestor's path with trailing slash is a prefix of child's
+ // path.
+ var ancestorPath = ancestorEntry.fullPath;
+ if (ancestorPath.slice(-1) !== '/')
+ ancestorPath += '/';
+ return childEntry.fullPath.indexOf(ancestorPath) === 0;
};
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698