|
|
|
@ -2,7 +2,7 @@
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
|
|
#define DEFAULT_PATH "/index.html"
|
|
|
|
|
#define DEFAULT_PATH "/"
|
|
|
|
|
|
|
|
|
|
char* url_to_proto(char* url) {
|
|
|
|
|
size_t length = strlen(url);
|
|
|
|
@ -68,8 +68,12 @@ char* url_to_path(char* url) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sentinel == 0) {
|
|
|
|
|
to_return = DEFAULT_PATH;
|
|
|
|
|
if (num_slashes < 3 || sentinel == str_len) { /* If we don't find the requisite number of slashes after
|
|
|
|
|
parsing the string OR the third slash is at the end of the string
|
|
|
|
|
("e.g. www.example.com/")... */
|
|
|
|
|
|
|
|
|
|
strcpy(to_return,DEFAULT_PATH); /* ...Then return the default path - "/" */
|
|
|
|
|
return to_return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Copy all bytes of the string, starting from the third slash */
|
|
|
|
|