Skip to content

Commit 89b069b

Browse files
authored
Merge pull request #208 from ipfs-shipyard/fix/incorrect-encoding
use correct version of method to URL encode string
2 parents 49bd34a + 61f7a9b commit 89b069b

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/main/java/io/ipfs/api/IPFS.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public List<MerkleNode> add(List<NamedStreamable> files, boolean wrap, boolean h
127127
m.addSubtree(Paths.get(""), file);
128128
} else
129129
m.addFilePart("file", Paths.get(""), file);
130-
};
130+
}
131131
String res = m.finish();
132132
return JSONParser.parseStream(res).stream()
133133
.map(x -> MerkleNode.fromJSON((Map<String, Object>) x))
@@ -145,7 +145,7 @@ public List<MerkleNode> add(List<NamedStreamable> files, AddArgs args) throws IO
145145
m.addSubtree(Paths.get(""), file);
146146
} else
147147
m.addFilePart("file", Paths.get(""), file);
148-
};
148+
}
149149
String res = m.finish();
150150
return JSONParser.parseStream(res).stream()
151151
.map(x -> MerkleNode.fromJSON((Map<String, Object>) x))
@@ -420,10 +420,8 @@ public Object peers(String topic) throws IOException {
420420

421421
/**
422422
*
423-
* @param topic
423+
* @param topic topic to publish to
424424
* @param data url encoded data to be published
425-
* @return
426-
* @throws IOException
427425
*/
428426
public void pub(String topic, String data) {
429427
String encodedTopic = Multibase.encode(Multibase.Base.Base64Url, topic.getBytes());
@@ -471,7 +469,7 @@ public List<Map> codecs(boolean numeric, boolean supported) throws IOException
471469
}
472470

473471
public Map format(Cid hash, Optional<String> f, Optional<String> v, Optional<String> mc, Optional<String> b) throws IOException {
474-
String fArg = f.isPresent() ? "&f=" + URLEncoder.encode(f.get()) : "";
472+
String fArg = f.isPresent() ? "&f=" + URLEncoder.encode(f.get(), "UTF-8") : "";
475473
String vArg = v.isPresent() ? "&v=" + v.get() : "";
476474
String mcArg = mc.isPresent() ? "&mc=" + mc.get() : "";
477475
String bArg = b.isPresent() ? "&b=" + b.get() : "";

0 commit comments

Comments
 (0)