diff options
author | Adam Domurad <[email protected]> | 2013-01-30 12:01:11 -0500 |
---|---|---|
committer | Adam Domurad <[email protected]> | 2013-01-30 12:01:11 -0500 |
commit | 8dd0f50c259ff8119cc9a801d87ed2fce44fbb09 (patch) | |
tree | 0997666dc73d835b7a91d727504e60b94e215dad /netx/net/sourceforge | |
parent | e2959ae96078602cf8b964a62bf454b364129c08 (diff) |
Fix for PR1292: Javaws does not resolve versioned jar names with periods properly
Diffstat (limited to 'netx/net/sourceforge')
-rw-r--r-- | netx/net/sourceforge/jnlp/cache/ResourceUrlCreator.java | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/netx/net/sourceforge/jnlp/cache/ResourceUrlCreator.java b/netx/net/sourceforge/jnlp/cache/ResourceUrlCreator.java index 8b49097..68ab009 100644 --- a/netx/net/sourceforge/jnlp/cache/ResourceUrlCreator.java +++ b/netx/net/sourceforge/jnlp/cache/ResourceUrlCreator.java @@ -102,9 +102,9 @@ public class ResourceUrlCreator { * @param resource the resource * @param usePack whether the URL should point to the pack200 file * @param useVersion whether the URL should be modified to include the version - * @return a URL for the resource or null if an appropraite URL can not be found + * @return a URL for the resource or null if an appropriate URL can not be found */ - protected URL getUrl(Resource resource, boolean usePack, boolean useVersion) { + static URL getUrl(Resource resource, boolean usePack, boolean useVersion) { if (!(usePack || useVersion)) { throw new IllegalArgumentException("either pack200 or version required"); } @@ -116,10 +116,21 @@ public class ResourceUrlCreator { } String filename = location.substring(lastSlash + 1); if (useVersion && resource.requestVersion != null) { - String parts[] = filename.split("\\.", 2); - String name = parts[0]; - String extension = parts[1]; - filename = name + "__V" + resource.requestVersion + "." + extension; + // With 'useVersion', j2-commons-cli.jar becomes, for example, j2-commons-cli__V1.0.jar + String parts[] = filename.split("\\.", -1 /* Keep blank strings*/); + + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < parts.length; i++) { + sb.append(parts[i]); + // Append __V<number> before last '.' + if (i == parts.length -2) { + sb.append("__V" + resource.requestVersion); + } + sb.append('.'); + } + sb.setLength(sb.length() - 1); // remove last '.' + + filename = sb.toString(); } if (usePack) { filename = filename + ".pack.gz"; |