Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit f11b7e8

Browse files
committed
Fallback to lower case version of README.md if needed.
1 parent 147055e commit f11b7e8

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

app/src/main/java/com/fox2code/mmm/markdown/MarkdownActivity.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import com.fox2code.mmm.utils.Http;
1818
import com.fox2code.mmm.utils.IntentHelper;
1919

20+
import java.io.IOException;
2021
import java.nio.charset.StandardCharsets;
2122

2223

@@ -60,7 +61,18 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
6061
new Thread(() -> {
6162
try {
6263
Log.d(TAG, "Downloading");
63-
String markdown = new String(Http.doHttpGet(url, true), StandardCharsets.UTF_8);
64+
byte[] rawMarkdown;
65+
try {
66+
rawMarkdown = Http.doHttpGet(url, true);
67+
} catch (IOException e) {
68+
// Workaround GitHub README.md case sensitivity issue
69+
if (url.startsWith("https://raw.githubusercontent.com/") &&
70+
url.endsWith("/README.md")) { // Try with lowercase version
71+
rawMarkdown = Http.doHttpGet(url.substring(0,
72+
url.length() - 9) + "readme.md", true);
73+
} else throw e;
74+
}
75+
String markdown = new String(rawMarkdown, StandardCharsets.UTF_8);
6476
Log.d(TAG, "Done!");
6577
runOnUiThread(() -> {
6678
MainApplication.getINSTANCE().getMarkwon().setMarkdown(

0 commit comments

Comments
 (0)