Skip to content
This repository has been archived by the owner on Sep 30, 2021. It is now read-only.

fix: viewer can't open image from markdown links (fix #1266) #2926

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Changes from all 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
14 changes: 13 additions & 1 deletion app/src/main/java/com/prettifier/pretty/PrettifyWebView.java
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,19 @@ public void setEnableNestedScrolling(boolean enableNestedScrolling) {
private void startActivity(@Nullable Uri url) {
if (url == null) return;
if (MarkDownProvider.isImage(url.toString())) {
CodeViewerActivity.startActivity(getContext(), url.toString(), url.toString());
String rawUrl;
if ("github.com".equals(url.getAuthority()) && "blob".equals(url.getPathSegments().get(2))) {
rawUrl = url
.buildUpon()
.authority("raw.githubusercontent.com")
.build()
.toString()
.replace("blob/", "");
} else {
rawUrl = url.toString();
}

CodeViewerActivity.startActivity(getContext(), rawUrl, url.toString());
} else {
String lastSegment = url.getEncodedFragment();
if (lastSegment != null || url.toString().startsWith("#") || url.toString().indexOf('#') != -1) {
Expand Down