Fix string checks

This commit is contained in:
blankie 2022-07-12 14:28:40 +07:00
parent 42ca1a016c
commit ecc1e4b443
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 12 additions and 9 deletions

View File

@ -38,29 +38,32 @@ public class ShareActivity extends Activity {
}
final Uri urlParsed = Uri.parse(urlString);
logVariable("scheme", urlParsed.getScheme());
if (urlParsed.getScheme() != "http" && urlParsed.getScheme() != "https" &&
urlParsed.getScheme() != "") {
final String scheme = urlParsed.getScheme();
logVariable("scheme", scheme);
if (scheme != null && !scheme.equals("") && !scheme.equals("http") &&
!scheme.equals("https")) {
Toast.makeText(getApplicationContext(), R.string.unknown_scheme,
Toast.LENGTH_SHORT).show();
return;
}
logVariable("host", urlParsed.getHost());
if (urlParsed.getHost() == null || (urlParsed.getHost() != "youtube.com" &&
urlParsed.getHost().endsWith(".youtube.com"))) {
final String host = urlParsed.getHost();
logVariable("host", host);
if (host == null || (!host.equals("youtube.com") &&
!host.endsWith(".youtube.com"))) {
Toast.makeText(getApplicationContext(), R.string.non_youtube_url,
Toast.LENGTH_SHORT).show();
return;
}
logVariable("path", urlParsed.getPath());
if (urlParsed.getPath() == null) {
final String path = urlParsed.getPath();
logVariable("path", path);
if (path == null) {
Toast.makeText(getApplicationContext(), R.string.null_path,
Toast.LENGTH_SHORT).show();
return;
}
if (!urlParsed.getPath().startsWith("/shorts/")) {
if (!path.startsWith("/shorts/")) {
Toast.makeText(getApplicationContext(), R.string.non_shorts_url,
Toast.LENGTH_SHORT).show();
return;