diff --git a/src/android/com/crypt/cordova/DecryptResource.java b/src/android/com/crypt/cordova/DecryptResource.java index 2cd9b51..fde3c45 100644 --- a/src/android/com/crypt/cordova/DecryptResource.java +++ b/src/android/com/crypt/cordova/DecryptResource.java @@ -14,6 +14,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStreamReader; +import java.util.regex.Pattern; import javax.crypto.Cipher; import javax.crypto.SecretKey; @@ -28,12 +29,8 @@ public class DecryptResource extends CordovaPlugin { private static final String CRYPT_KEY = ""; private static final String CRYPT_IV = ""; - private static final String[] CRYPT_FILES = { - ".htm", - ".html", - ".js", - ".css", - }; + private static final String[] INCLUDE_FILES = new String[] { }; + private static final String[] EXCLUDE_FILES = new String[] { }; private String URL_PREFIX; private String launchUri; @@ -102,12 +99,23 @@ private String tofileUri(String uri) { return uri; } - private boolean isCryptFiles(String uri) { - for (String ext: CRYPT_FILES) { - if (uri.endsWith(ext)) { - return true; + private boolean isCryptFiles(String uri) { + String checkPath = uri.replace("file:///android_asset/www/", ""); + if (!this.hasMatch(checkPath, INCLUDE_FILES)) { + return false; + } + if (this.hasMatch(checkPath, EXCLUDE_FILES)) { + return false; } + return true; + } + + private boolean hasMatch(String text, String[] regexArr) { + for (String regex : regexArr) { + if (Pattern.compile(regex).matcher(text).find()) { + return true; + } + } + return false; } - return false; - } }