Skip to content

Commit ef10f2f

Browse files
committed
addtional support for jar and file in AjaxURLConnection
1 parent 04198c4 commit ef10f2f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

sources/net.sf.j2s.java.core/src/javajs/util/AjaxURLConnection.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,14 @@ private Object doAjax(boolean isBinary, Function<Object, Void> whenDone) {
197197
responseCode = (isEmpty ? HTTP_NOT_FOUND : HTTP_ACCEPTED);
198198
} else {
199199
if (myURL.startsWith("file:")) {
200-
myURL = JSUtil.J2S.getResourcePath("", true) + myURL.substring(5);
200+
String path = JSUtil.J2S.getResourcePath("", true);
201+
String base = JSUtil.getAppletDocumentPath();
202+
if (myURL.indexOf(path) >= 0)
203+
myURL = path + myURL.split(path)[1];
204+
else if (base != null && myURL.indexOf(base) == 0)
205+
myURL = myURL.substring(base.length());
206+
else
207+
myURL = path + myURL.substring(5);
201208
}
202209
result = J2S.doAjax(myURL, postOut, bytesOut, info);
203210
if (whenDone != null)

0 commit comments

Comments
 (0)