Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve wiki link handling #1184

Merged
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class LinkResolverActivity extends AppCompatActivity {
private static final String IMGUR_ALBUM_PATTERN = "/(album|a)/\\w+/?";
private static final String IMGUR_IMAGE_PATTERN = "/\\w+/?";
private static final String RPAN_BROADCAST_PATTERN = "/rpan/r/[\\w-]+/\\w+/?\\w+/?";
private static final String WIKI_PATTERN = "/[rR]/[\\w-]+/(wiki|w)?(?:/\\w+)+";
private static final String WIKI_PATTERN = "/[rR]/[\\w-]+/(wiki|w)?(?:/?[\\w-]+)+";
Fixed Show fixed Hide fixed
private static final String GOOGLE_AMP_PATTERN = "/amp/s/amp.reddit.com/.*";
private static final String STREAMABLE_PATTERN = "/\\w+/?";

Expand Down Expand Up @@ -204,7 +204,17 @@ private void handleUri(Uri uri) {
deepLinkError(uri);
}
} else if (path.matches(WIKI_PATTERN)) {
final String wikiPage = path.substring(path.lastIndexOf("/wiki/") + 6);
String[] pathSegments = path.split("/");
String wikiPage;
if (pathSegments.length == 4) {
wikiPage = "index";
} else {
int lengthThroughWiki = 0;
for (int i = 1; i <= 3; ++i) {
lengthThroughWiki += pathSegments[i].length() + 1;
}
wikiPage = path.substring(lengthThroughWiki);
}
Intent intent = new Intent(this, WikiActivity.class);
intent.putExtra(WikiActivity.EXTRA_SUBREDDIT_NAME, segments.get(1));
intent.putExtra(WikiActivity.EXTRA_WIKI_PATH, wikiPage);
Expand Down