diff options
Diffstat (limited to 'tests/test-extensions/net')
-rw-r--r-- | tests/test-extensions/net/sourceforge/jnlp/TinyHttpdImpl.java | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test-extensions/net/sourceforge/jnlp/TinyHttpdImpl.java b/tests/test-extensions/net/sourceforge/jnlp/TinyHttpdImpl.java index 561926a..4ef6450 100644 --- a/tests/test-extensions/net/sourceforge/jnlp/TinyHttpdImpl.java +++ b/tests/test-extensions/net/sourceforge/jnlp/TinyHttpdImpl.java @@ -127,6 +127,7 @@ public class TinyHttpdImpl extends Thread { p = URLDecoder.decode(p, "UTF-8"); p = p.replaceAll("\\?.*", ""); p = (".".concat((p.endsWith("/")) ? p.concat("index.html") : p)).replace('/', File.separatorChar); + p = stripHttpPathParams(p); ServerAccess.logNoReprint("Serving: " + p); File pp = new File(dir, p); int l = (int) pp.length(); @@ -203,4 +204,27 @@ public class TinyHttpdImpl extends Thread { } return array; } + + /** + * This function removes the HTTP Path Parameter from a given JAR URL, assuming that the + * path param delimiter is a semicolon + * @param url - the URL from which to remove the path parameter + * @return the URL with the path parameter removed + */ + public static String stripHttpPathParams(String url) { + if (url == null) { + return null; + } + + // If JNLP specifies JAR URL with .JAR extension (as it should), then look for any semicolons + // after this position. If one is found, remove it and any following characters. + int fileExtension = url.toUpperCase().lastIndexOf(".JAR"); + if (fileExtension != -1) { + int firstSemiColon = url.indexOf(';', fileExtension); + if (firstSemiColon != -1) { + url = url.substring(0, firstSemiColon); + } + } + return url; + } } |