diff --git a/src/node.c b/src/node.c index bc33da7..2bbbe7c 100644 --- a/src/node.c +++ b/src/node.c @@ -163,9 +163,6 @@ int r3_tree_compile_patterns(node * n, char **errstr) { p = cpat; - strncat(p, "^", 1); - p++; - edge *e = NULL; int opcode_cnt = 0; for ( int i = 0 ; i < n->edge_len ; i++ ) { @@ -179,7 +176,8 @@ int r3_tree_compile_patterns(node * n, char **errstr) { char * slug_pat = slug_compile(e->pattern, e->pattern_len); strcat(p, slug_pat); } else { - strncat(p++,"(", 1); + strncat(p,"^(", 2); + p += 2; strncat(p, e->pattern, e->pattern_len); p += e->pattern_len; diff --git a/tests/check_slug.c b/tests/check_slug.c index ca42f85..f916c3a 100644 --- a/tests/check_slug.c +++ b/tests/check_slug.c @@ -88,7 +88,7 @@ START_TEST (test_slug_count) ck_assert_int_eq( slug_count(pattern, strlen(pattern), NULL), 2 ); char * pattern2 = "/user/{name:\\d{3}}/to/{id}"; - ck_assert_int_eq( slug_count(pattern2, strlen(pattern), NULL), 2 ); + ck_assert_int_eq( slug_count(pattern2, strlen(pattern2), NULL), 2 ); } END_TEST