Skip to content

Commit 99c0b7e

Browse files
committed
Add pathExaminer.concatenate
1 parent 4454dd4 commit 99c0b7e

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/main/java/httpserver/file/PathExaminer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.nio.file.Paths;
88
import java.util.ArrayList;
99
import java.util.List;
10+
import java.util.WeakHashMap;
1011

1112
import static java.nio.file.Files.*;
1213

@@ -54,4 +55,8 @@ public Path[] directoryContents(Path dir) {
5455
}
5556
return result.toArray(new Path[0]);
5657
}
58+
59+
public Path concatenate(Path root, String suffix) {
60+
return Paths.get(root.toString(), suffix);
61+
}
5762
}

src/test/java/httpserver/file/PathExaminerTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,13 @@ public void makesRootPathFromStringInput() throws Exception {
9595
assertEquals(Paths.get("/Users", "example", "public"),
9696
pathExaminer.getPath(input2));
9797
}
98+
99+
@Test
100+
public void concatenatesTwoPaths() throws Exception {
101+
Path path = Paths.get("/example", "test");
102+
String suffix = "logs";
103+
104+
String expected = "/example/test/logs";
105+
assertEquals(expected, pathExaminer.concatenate(path, suffix).toString());
106+
}
98107
}

0 commit comments

Comments
 (0)