Skip to content

Commit 3ed731d

Browse files
committed
Update link formatting to conform to Fitnesse
1 parent 2fe6df4 commit 3ed731d

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/main/java/httpserver/file/Html.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static String hrefString(Path root, Path fullFilePath) {
1313

1414
public static String linkString(Path root, Path fullFilePath) {
1515
String href = hrefString(root, fullFilePath);
16-
return "<div><a href=\"" + href +
17-
"\">" + href + "</a></div>";
16+
return "<div><a href=\"/" + href +
17+
"\">/" + href + "</a></div>";
1818
}
1919
}

src/test/java/httpserver/SocketHandlerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public void writesContentTypeForGif() throws Exception {
5656

5757
@Test
5858
public void writesRequestedDirContentsAsHtmlToOutputStreamForGET() throws Exception {
59-
String expectedBody = "<div><a href=\"" + relativePath1 + "\">" + relativePath1 + "</a></div>" +
60-
"<div><a href=\"" + relativePath2 + "\">" + relativePath2 + "</a></div>";
59+
String expectedBody = "<div><a href=\"/" + relativePath1 + "\">/" + relativePath1 + "</a></div>" +
60+
"<div><a href=\"/" + relativePath2 + "\">/" + relativePath2 + "</a></div>";
6161

6262
byte[] request = ("GET / HTTP/1.1\r\nHost: 127.0.0.1:5000\r\n\r\n").getBytes();
6363

src/test/java/httpserver/file/HtmlTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ public void makesHtmlLinkFromRootPathAndDirPath() throws Exception {
4444
.substring(root.toString().length() + 1);
4545
String expectedDirPath = fullDirPath.toString()
4646
.substring(root.toString().length() + 1) + "/";
47-
String expectedFileLink = "<div><a href=\"" + expectedFilePath +
48-
"\">" + expectedFilePath + "</a></div>";
49-
String expectedDirLink = "<div><a href=\"" + expectedDirPath +
50-
"\">" + expectedDirPath + "</a></div>";
47+
String expectedFileLink = "<div><a href=\"/" + expectedFilePath +
48+
"\">/" + expectedFilePath + "</a></div>";
49+
String expectedDirLink = "<div><a href=\"/" + expectedDirPath +
50+
"\">/" + expectedDirPath + "</a></div>";
5151

5252
assertEquals(expectedFileLink, Html.linkString(root, fullFilePath));
5353
assertEquals(expectedDirLink, Html.linkString(root, fullDirPath));

0 commit comments

Comments
 (0)