Skip to content
This repository was archived by the owner on May 7, 2025. It is now read-only.

Commit 7f964be

Browse files
committed
BUG 74: Fixed cleanResourceUrl() so that the 'file:///' base path is handled correctly
1 parent e969514 commit 7f964be

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

SDKLauncher-Android/src/org/readium/sdk/android/launcher/WebViewActivity.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,13 @@ public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
341341
}
342342

343343
private String cleanResourceUrl(String url) {
344-
String cleanUrl = url.replace(ASSET_PREFIX, "");
345-
cleanUrl = (cleanUrl.startsWith(mPackage.getBasePath())) ? cleanUrl.replaceFirst(mPackage.getBasePath(), "") : cleanUrl;
344+
// Get the correct base path
345+
String basePath = mPackage.getBasePath().replaceFirst("file://", "");
346+
// Clean assets prefix
347+
String cleanUrl = (url.startsWith(ASSET_PREFIX)) ? url.replaceFirst(ASSET_PREFIX, "") : url.replaceFirst("file://", "");
348+
// Clean the package base path if needed
349+
cleanUrl = (cleanUrl.startsWith(basePath)) ? cleanUrl.replaceFirst(basePath, "") : cleanUrl;
350+
// Clean anything after sharp
346351
int indexOfSharp = cleanUrl.indexOf('#');
347352
if (indexOfSharp >= 0) {
348353
cleanUrl = cleanUrl.substring(0, indexOfSharp);

0 commit comments

Comments
 (0)