Part two of the changes from protected to public.
This commit is contained in:
parent
3d3b8d56fa
commit
d0de8dacd4
|
@ -40,33 +40,39 @@ class AllScriptsExtractor(apkUnzipDir: File) extends DefaultSourceExtractor {
|
||||||
val AbsolutePathRegex = """.+android_asset/(.+)""".r
|
val AbsolutePathRegex = """.+android_asset/(.+)""".r
|
||||||
val RemotePathRegex = """(https?://.+)""".r
|
val RemotePathRegex = """(https?://.+)""".r
|
||||||
|
|
||||||
override def getScriptFromUrl(urlString: String, scriptTag: ITag) = {
|
override def handleScript(tag: ITag) = {
|
||||||
try {
|
val content = tag.getAttributeByName("src");
|
||||||
// For some reason, some people use absolute script paths in their Cordova apps...
|
if (content != null) {
|
||||||
val scriptSrc = urlString match {
|
val urlString = content.fst
|
||||||
case AbsolutePathRegex(rel) => new File(new File(apkUnzipDir, "assets"), rel).toURI().toURL()
|
try {
|
||||||
case RemotePathRegex(urlString) => {
|
// For some reason, some people use absolute script paths in their Cordova apps...
|
||||||
val url = new URL(urlString)
|
val scriptSrc = urlString match {
|
||||||
logger.debug(s"Downloading $urlString...")
|
case AbsolutePathRegex(rel) => new File(new File(apkUnzipDir, "assets"), rel).toURI().toURL()
|
||||||
val dest = new File(new File(apkUnzipDir, "downloaded"), url.getFile)
|
case RemotePathRegex(urlString) => {
|
||||||
dest.getParentFile.mkdirs()
|
val url = new URL(urlString)
|
||||||
val stream = url.openStream()
|
logger.debug(s"Downloading $urlString...")
|
||||||
FileUtils.copyInputStreamToFile(stream, dest)
|
val dest = new File(new File(apkUnzipDir, "downloaded"), url.getFile)
|
||||||
IOUtils.closeQuietly(stream)
|
dest.getParentFile.mkdirs()
|
||||||
dest.toURI().toURL()
|
val stream = url.openStream()
|
||||||
|
FileUtils.copyInputStreamToFile(stream, dest)
|
||||||
|
IOUtils.closeQuietly(stream)
|
||||||
|
dest.toURI().toURL()
|
||||||
|
}
|
||||||
|
case _ => new URL(entrypoint, urlString)
|
||||||
}
|
}
|
||||||
case _ => new URL(entrypoint, urlString)
|
if (!new File(scriptSrc.getFile).isFile()) {
|
||||||
}
|
// Try again with all lower-case letter, otherwise files may be missed on case-sensitive file systems
|
||||||
if (!new File(scriptSrc.getFile).isFile()) {
|
if (!new File(scriptSrc.getFile.toLowerCase()).isFile()) {
|
||||||
// Try again with all lower-case letter, otherwise files may be missed on case-sensitive file systems
|
throw new IOException(s"$scriptSrc does not exist on the file system!")
|
||||||
if (!new File(scriptSrc.getFile.toLowerCase()).isFile()) {
|
}
|
||||||
throw new IOException(s"$scriptSrc does not exist on the file system!")
|
|
||||||
}
|
}
|
||||||
|
extractedScripts += scriptSrc
|
||||||
|
} catch {
|
||||||
|
case ioe: IOException => logger.warn(s"Could not fetch script $urlString!", ioe)
|
||||||
}
|
}
|
||||||
extractedScripts += scriptSrc
|
|
||||||
} catch {
|
|
||||||
case ioe: IOException => logger.warn(s"Could not fetch script $urlString!", ioe)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue