Skip to content

Instantly share code, notes, and snippets.

@kuroneko
Created November 13, 2013 05:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kuroneko/7444401 to your computer and use it in GitHub Desktop.
Save kuroneko/7444401 to your computer and use it in GitHub Desktop.
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