feat: use extended regex

c-web-server
Jef Roosens 2023-05-31 11:49:49 +02:00
parent bbfea5876e
commit 5d0cafbc27
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
2 changed files with 4 additions and 4 deletions

View File

@ -70,7 +70,7 @@ void http_loop_run(event_loop *el, int port) {
if (route->type == http_route_regex) {
regex_t *r = calloc(sizeof(regex_t), 1);
if (regcomp(r, route->path, 0) != 0) {
if (regcomp(r, route->path, REG_EXTENDED) != 0) {
critical(1, "RegEx expression '%s' failed to compile", route->path);
}

View File

@ -9,16 +9,16 @@ http_route lander_routes[] = {
.steps = {lander_get_index, NULL}},
{.type = http_route_regex,
.method = http_get,
.path = "^/\\([^/]\\+\\)$",
.path = "^/([^/]+)$",
.steps = {lander_get_entry, NULL}},
{.type = http_route_regex,
.method = http_post,
.path = "^/s\\(l\\?\\)/\\([^/]*\\)$",
.path = "^/s(l?)/([^/]*)$",
.steps = {http_loop_step_auth, http_loop_step_body_to_buf,
lander_post_redirect, NULL}},
{.type = http_route_regex,
.method = http_post,
.path = "^/p\\(l\\?\\)/\\([^/]*\\)$",
.path = "^/p(l?)/([^/]*)$",
.steps = {http_loop_step_auth, lander_post_paste,
http_loop_step_body_to_file, http_loop_step_switch_res, NULL}},
};