Fixed bug relating to DEFAULT_PATH in url_to_path function
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#define DEFAULT_PATH "/index.html"
|
#define DEFAULT_PATH "/"
|
||||||
|
|
||||||
char* url_to_proto(char* url) {
|
char* url_to_proto(char* url) {
|
||||||
size_t length = strlen(url);
|
size_t length = strlen(url);
|
||||||
@@ -68,8 +68,12 @@ char* url_to_path(char* url) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sentinel == 0) {
|
if (num_slashes < 3 || sentinel == str_len) { /* If we don't find the requisite number of slashes after
|
||||||
to_return = DEFAULT_PATH;
|
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 */
|
/* Copy all bytes of the string, starting from the third slash */
|
||||||
|
Reference in New Issue
Block a user