public static Repository getRepository(Uri uri) {
        List<String> segments = uri.getPathSegments();
        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);
    }
Attempt to parse a {@link Repository} from the given {@link Uri}

@param uri
@return {@link Repository} or null if unparseable
app/src/main/java/com/github/pockethub/android/core/repo/RepositoryUriMatcher.java