Skip to content

remove double encoding. issue: 111 #207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/main/java/io/ipfs/api/NamedStreamable.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ public List<NamedStreamable> getChildren() {
}

public Optional<String> getName() {
try {
return Optional.of(URLEncoder.encode(source.getName(), "UTF-8"));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
return Optional.of(source.getName());
}
}

Expand Down
9 changes: 9 additions & 0 deletions src/test/java/io/ipfs/api/SimpleAddTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ public void testAddArgs() throws Exception {
Assert.assertEquals(1, tree.size());
Assert.assertEquals("index.html", tree.get(0).name.get());
}
@Test
public void testFilenameEncoding() throws Exception {
Path path = Paths.get("src/test/resources/folder/你好.html");
NamedStreamable file = new FileWrapper(path.toFile());
List<MerkleNode> tree = ipfs.add(file);

Assert.assertEquals(1, tree.size());
Assert.assertEquals("你好.html", tree.get(0).name.get());
}

@Test
public void testSingleWrapped() throws Exception {
Expand Down
10 changes: 10 additions & 0 deletions src/test/resources/folder/你好.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Blank page</title>
<meta charset="utf-8" />
</head>
<body>
<h1>blank</h1>
</body>
</html>