public static Gist getGist(final Uri uri) {
        List<String> segments = uri.getPathSegments();
        if (segments.size() != 1) {
            return null;
        }

        String gistId = segments.get(0);
        if (TextUtils.isEmpty(gistId)) {
            return null;
        }

        Gist gist = Gist.builder()
                .id(gistId)
                .build();

        if (TextUtils.isDigitsOnly(gistId)) {
            return gist;
        }

        if (PATTERN.matcher(gistId).matches()) {
            return gist;
        }

        return null;
    }
Parse a {@link Gist} from a non-null {@link Uri}

@param uri
@return {@link Gist} or null if none found in given {@link Uri}
app/src/main/java/com/github/pockethub/android/core/gist/GistUriMatcher.java