/** * Attempt to parse a {@link Repository} from the given {@link Uri} * * @param uri * @return {@link Repository} or null if unparseable */ public static Repository getRepository(Uri uri) { List<String> segments = uri.getPathSegments(); if (segments == null) return null; if (segments.size() < 2) return null; String repoOwner = segments.get(0); if (!RepositoryUtils.isValidOwner(repoOwner)) return null; String repoName = segments.get(1); if (!RepositoryUtils.isValidRepo(repoName)) return null; return InfoUtils.createRepoFromData(repoOwner, repoName); }