Added a small improvement to url parsing

This commit is contained in:
PaulStets 2018-04-14 14:05:58 +03:00
parent 1c44ec042f
commit a27e0ca555

View file

@ -40,7 +40,7 @@ public class CustomWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.contains(WEB_DOMAIN)) {
String lang = url.substring(url.indexOf(PAGE_PREFIX) + PAGE_PREFIX.length(), url.indexOf("."));
String lang = url.substring(url.startsWith(PAGE_PREFIX) ? PAGE_PREFIX.length() : 0, url.indexOf("."));
String articleName = url.replace(PAGE_PREFIX + lang + WEB_DOMAIN, "")
.replaceAll("_", " ");
try {