Bug 1405021 - Use web app origin as default scope r=droeh draft
authorJames Willcox <snorp@snorp.net>
Mon, 02 Oct 2017 13:34:54 -0500
changeset 673752 bf3da5473f40b399d32c47d35f7573251d95a25a
parent 673747 05cb92826ff4ea5fc4227e26c1b339f68778b0da
child 673812 927401ec1692c385823e7c747d8be8ba5b8cd5fa
push id82630
push userbmo:snorp@snorp.net
push dateMon, 02 Oct 2017 18:35:35 +0000
reviewersdroeh
bugs1405021
milestone58.0a1
Bug 1405021 - Use web app origin as default scope r=droeh MozReview-Commit-ID: EwxR6mQITmy
mobile/android/base/java/org/mozilla/gecko/webapps/WebAppManifest.java
--- a/mobile/android/base/java/org/mozilla/gecko/webapps/WebAppManifest.java
+++ b/mobile/android/base/java/org/mozilla/gecko/webapps/WebAppManifest.java
@@ -168,31 +168,38 @@ public class WebAppManifest {
         final LoadFaviconResult loadIconResult = FaviconDecoder
             .decodeDataURI(GeckoAppShell.getApplicationContext(), iconStr);
         if (loadIconResult == null) {
             return null;
         }
         return loadIconResult.getBestBitmap(GeckoAppShell.getPreferredIconSize());
     }
 
+    private static Uri stripPath(final Uri uri) {
+        return new Uri.Builder()
+            .scheme(uri.getScheme())
+            .authority(uri.getAuthority())
+            .build();
+    }
+
     private static Uri stripLastPathSegment(final Uri uri) {
         final Uri.Builder builder = new Uri.Builder()
             .scheme(uri.getScheme())
             .authority(uri.getAuthority());
 
         final List<String> segments = uri.getPathSegments();
         for (int i = 0; i < (segments.size() - 1); i++) {
             builder.appendPath(segments.get(i));
         }
 
         return builder.build();
     }
 
     private Uri readScope(final JSONObject manifest) {
-        final Uri defaultScope = stripLastPathSegment(mStartUri);
+        final Uri defaultScope = stripPath(mStartUri);
         final String scopeStr = manifest.optString("scope", null);
         if (scopeStr == null) {
             return defaultScope;
         }
 
         Uri scope = Uri.parse(scopeStr);
         if (scope == null) {
             return defaultScope;