Created
November 13, 2013 05:55
-
-
Save kuroneko/7444401 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/core/src/main/java/org/jruby/runtime/load/LoadService.java b/core/src/main/java/org/jruby/runtime/load/LoadService.java | |
index 4f457be..5d1ce7d 100644 | |
--- a/core/src/main/java/org/jruby/runtime/load/LoadService.java | |
+++ b/core/src/main/java/org/jruby/runtime/load/LoadService.java | |
@@ -1392,23 +1392,23 @@ public class LoadService { | |
} | |
private String[] splitJarUrl(String loadPathEntry) { | |
- int idx = loadPathEntry.indexOf("!"); | |
- if (idx == -1) { | |
- return new String[]{loadPathEntry, ""}; | |
- } | |
- | |
- String filename = loadPathEntry.substring(0, idx); | |
- String entry = idx + 2 < loadPathEntry.length() ? loadPathEntry.substring(idx + 2) : ""; | |
- | |
- if(filename.startsWith("jar:")) { | |
- filename = filename.substring(4); | |
- } | |
- | |
- if(filename.startsWith("file:")) { | |
- filename = filename.substring(5); | |
- } | |
- | |
- return new String[]{filename, entry}; | |
+ String[] components = loadPathEntry.split("!", 2); | |
+ if (components.length != 2) { | |
+ components = new String[]{components[0], ""}; | |
+ } | |
+ try { | |
+ URI jarURI = new URI(components[0]); | |
+ if (jarURI.getScheme() == "file" || jarURI.getScheme() == "jar") { | |
+ // decode the file or jar URI appropriately | |
+ components[0] = jarURI.getSchemeSpecificPart(); | |
+ } | |
+ } catch (URISyntaxException ex) { | |
+ // not a URI | |
+ } | |
+ if (components[1].length() == 1) { | |
+ components[1] = ""; | |
+ } | |
+ return components; | |
} | |
protected LoadServiceResource tryResourceFromLoadPath( String namePlusSuffix,String loadPathEntry) throws RaiseException { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment