diff --git a/android/src/main/java/com/web3webview/InputStreamWithInjectedJS.java b/android/src/main/java/com/web3webview/InputStreamWithInjectedJS.java index fd534af..6e5f328 100644 --- a/android/src/main/java/com/web3webview/InputStreamWithInjectedJS.java +++ b/android/src/main/java/com/web3webview/InputStreamWithInjectedJS.java @@ -25,6 +25,7 @@ public class InputStreamWithInjectedJS extends InputStream { private boolean hasJS = false; private boolean headWasFound = false; private boolean scriptWasInjected = false; + private boolean openingHeadFound = false; private StringBuffer contentBuffer = new StringBuffer(); private static Charset getCharset(String charsetName) { Charset cs = UTF_8; @@ -63,6 +64,7 @@ public int read() throws IOException { if (scriptWasInjected || !hasJS) { return pageIS.read(); } + if (!scriptWasInjected && headWasFound) { int nextByte = scriptIS.read(); if (nextByte == -1) { @@ -75,12 +77,22 @@ public int read() throws IOException { } if (!headWasFound) { int nextByte = pageIS.read(); - contentBuffer.append((char) nextByte); + char nextByteStr = (char) nextByte; + contentBuffer.append(nextByteStr); int bufferLength = contentBuffer.length(); - if (nextByte == 62 && bufferLength >= 6) { - if (contentBuffer.substring(bufferLength - 6).equals("")) { + String headString = "= 5) { + String stringToMatch = contentBuffer.substring(bufferLength - 5).toLowerCase(); + if (stringToMatch.contains(headString)) { + openingHeadFound = true; + } } } return nextByte; diff --git a/package.json b/package.json index 99f842e..e390322 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-web3-webview", - "version": "2.0.0", + "version": "2.0.1", "description": "A react native webview optimized for a web3 dApp browser application", "main": "index.js", "scripts": {