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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java

Issue 2711563003: Do not drop the final web app scope path component if it ends with a slash. (Closed)
Patch Set: Extra test for dir + fragment and query Created 3 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 | « no previous file | chrome/android/junit/src/org/chromium/chrome/browser/ShortcutHelperTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java b/chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java
index dac06697673f0c74635c5823fdecf9d1082d2981..769b9300a1828491f7a983e3c9a7f995ae95f074 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java
@@ -587,15 +587,17 @@ public class ShortcutHelper {
@CalledByNative
public static String getScopeFromUrl(String url) {
// Scope URL is generated by:
- // - Removing last component of the URL.
+ // - Removing last component of the URL if it does not end with a slash.
// - Clearing the URL's query and fragment.
Uri uri = Uri.parse(url);
List<String> path = uri.getPathSegments();
int endIndex = path.size();
- // If there is at least one path element, remove the last one.
- if (endIndex > 0) {
+ // Remove the last path element if there is at least one path element, *and* the path does
+ // not end with a slash. This means that URLs to specific files have the file component
+ // removed, but URLs to directories retain the directory.
+ if (endIndex > 0 && !uri.getPath().endsWith("/")) {
endIndex -= 1;
}
« no previous file with comments | « no previous file | chrome/android/junit/src/org/chromium/chrome/browser/ShortcutHelperTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698