Handle BlobPath's trailing separator case (#23091)

This commit is contained in:
mms-programming 2017-02-22 03:04:55 -05:00 committed by Tanguy Leroux
parent 148be11f26
commit d31e41547a
2 changed files with 3 additions and 1 deletions

View File

@ -63,7 +63,7 @@ public class BlobPath implements Iterable<String> {
public String buildAsString() {
String p = String.join(SEPARATOR, paths);
if (p.isEmpty()) {
if (p.isEmpty() || p.endsWith(SEPARATOR)) {
return p;
}
return p + SEPARATOR;

View File

@ -35,5 +35,7 @@ public class BlobPathTests extends ESTestCase {
path = path.add("b").add("c");
assertThat(path.buildAsString(), is("a/b/c/"));
path = path.add("d/");
assertThat(path.buildAsString(), is("a/b/c/d/"));
}
}