Example #1
0
 public URL[] toURLAry(JSHandle jsAry) throws java.net.MalformedURLException {
   int length = ((Number) jsAry.getMember("length")).intValue();
   URL[] ary = new URL[length];
   for (int i = 0; i < length; i++) {
     Object obj = jsAry.getSlot(i);
     if (obj == null) {
       continue;
     }
     String spec = obj.toString();
     if (!spec.matches("^\\w+:.+")) {
       String location = (String) handle.eval("document.location.toString()");
       spec = location.replaceFirst("/[^/]*$", "/" + spec);
     }
     ary[i] = new URL(spec);
   }
   return ary;
 }