diff --git a/vger.c b/vger.c index 04b3c12..0dad323 100644 --- a/vger.c +++ b/vger.c @@ -514,21 +514,6 @@ split_request(const char *request, char *hostname, char *path, char *query) char buf[BUFSIZ] = {'\0'}; /* to handle error messages */ int ret = 0; - const char *gemini_regex = "^gemini://+([^/|^\?]*)/*([^\?]*)[\?]?(.*)$"; - /* - * ^gemini://+ : in case of gemini:/// - * 1: hostname - * ([^/|^\?]*) : - * catch everything, stop when / or ? is found - * then skip multiple / - * 2: path - * ([^\?]*) : - * catch everything and stop at ? if any - * 3 : query - * [\?]?(.*)$: - * catch everything after ? if any - */ - if ((ret = regcomp(&greg, gemini_regex, REG_EXTENDED)) != 0) { regerror(ret, &greg, buf, sizeof(buf)); regfree(&greg); diff --git a/vger.h b/vger.h index 7a9f5db..9468d73 100644 --- a/vger.h +++ b/vger.h @@ -11,6 +11,22 @@ */ #define GEMINI_REQUEST_MAX 1025 +/* gemini_regex: + * ============= + * ^gemini://+ : in case of gemini:/// + * 1: hostname + * ([^/|^\?]*) : + * catch everything, stop when / or ? is found + * then skip multiple / + * 2: path + * ([^\?]*) : + * catch everything and stop at ? if any + * 3 : query + * [\?]?(.*)$: + * catch everything after ? if any + */ +const char *gemini_regex = "^gemini://+([^/|^\?]*)/*([^\?]*)[\?]?(.*)$"; + /* global vars */ static int _retcode = 0; static ssize_t _datasiz = 0;