@capacitor/android 5.7.1 → 5.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -69,12 +69,17 @@ class JSInjector {
|
|
|
69
69
|
* @return
|
|
70
70
|
*/
|
|
71
71
|
public InputStream getInjectedStream(InputStream responseStream) {
|
|
72
|
-
String js = "<script type=\"text/javascript\">" + getScriptString()
|
|
72
|
+
String js = "<script type=\"text/javascript\">" + getScriptString() + "</script>";
|
|
73
73
|
String html = this.readAssetStream(responseStream);
|
|
74
|
+
|
|
75
|
+
// Insert the js string at the position after <head> or before </head> using StringBuilder
|
|
76
|
+
StringBuilder modifiedHtml = new StringBuilder(html);
|
|
74
77
|
if (html.contains("<head>")) {
|
|
75
|
-
html
|
|
78
|
+
modifiedHtml.insert(html.indexOf("<head>") + "<head>".length(), "\n" + js + "\n");
|
|
79
|
+
html = modifiedHtml.toString();
|
|
76
80
|
} else if (html.contains("</head>")) {
|
|
77
|
-
html
|
|
81
|
+
modifiedHtml.insert(html.indexOf("</head>"), "\n" + js + "\n");
|
|
82
|
+
html = modifiedHtml.toString();
|
|
78
83
|
} else {
|
|
79
84
|
Logger.error("Unable to inject Capacitor, Plugins won't work");
|
|
80
85
|
}
|
package/package.json
CHANGED