Created
October 14, 2009 21:01
-
-
Save mhansen/210404 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Mark Hansen 1082336 */ | |
//uri is in the form /pages/mh168/ or form | |
public void URI2LocalPath(string uri) { | |
// convert directory listings to directory/index.html | |
if (uri.endsWith("/")) uri += "index.html"; | |
//remove first slash so java searches from the local directory, not the root of the filesystem | |
if (uri.startsWith("/")) uri.replaceFirst("/", ""); | |
} | |
public void testProcessGETRequest() { | |
String uri = "/pages/mark/"; | |
String expected = "pages/mark/index.html"; | |
String actual = URI2LocalPath(uri); | |
assertEquals(expected, actual); | |
uri = "/"; | |
expected = "index.html"; | |
actual = URI2LocalPath(uri); | |
assertEquals(expected, actual); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment