fix slug compile pattern
This commit is contained in:
parent
39fc24e3fa
commit
0636c9dad3
4 changed files with 12 additions and 7 deletions
|
@ -90,6 +90,9 @@ AM_CONDITIONAL(ENABLE_GRAPHVIZ, test "x$enable_graphviz" = "xyes")
|
||||||
|
|
||||||
AC_ARG_ENABLE(json, AS_HELP_STRING([--enable-json],[enable json encoder]))
|
AC_ARG_ENABLE(json, AS_HELP_STRING([--enable-json],[enable json encoder]))
|
||||||
if test "x$enable_json" = "xyes"; then
|
if test "x$enable_json" = "xyes"; then
|
||||||
|
PKG_CHECK_MODULES(JSONC, [json-c])
|
||||||
|
AC_SUBST(JSONC_CFLAGS)
|
||||||
|
AC_SUBST(JSONC_LIBS)
|
||||||
AC_DEFINE(ENABLE_JSON, 1, [enable json])
|
AC_DEFINE(ENABLE_JSON, 1, [enable json])
|
||||||
fi
|
fi
|
||||||
AM_CONDITIONAL(ENABLE_JSON, test "x$enable_json" = "xyes")
|
AM_CONDITIONAL(ENABLE_JSON, test "x$enable_json" = "xyes")
|
||||||
|
|
|
@ -190,6 +190,9 @@ char * slug_compile(const char * str, int len)
|
||||||
}
|
}
|
||||||
|
|
||||||
o = out;
|
o = out;
|
||||||
|
strncat(o, "^", 1);
|
||||||
|
o++;
|
||||||
|
|
||||||
strncat(o, str, s1 - str); // string before slug
|
strncat(o, str, s1 - str); // string before slug
|
||||||
o += (s1 - str);
|
o += (s1 - str);
|
||||||
|
|
||||||
|
|
|
@ -6,14 +6,13 @@
|
||||||
# endif
|
# endif
|
||||||
TESTS =
|
TESTS =
|
||||||
|
|
||||||
AM_CFLAGS=$(DEPS_CFLAGS) $(GVC_DEPS_CFLAGS) -I$(top_builddir) -I$(top_builddir)/include -I$(top_builddir)/3rdparty -Wall -std=c99 -ggdb -Wall
|
AM_CFLAGS=$(DEPS_CFLAGS) $(GVC_DEPS_CFLAGS) $(JSONC_CFLAGS) -I$(top_builddir) -I$(top_builddir)/include -I$(top_builddir)/3rdparty -Wall -std=c99 -ggdb -Wall
|
||||||
AM_LDFLAGS=$(DEPS_LIBS) $(GVC_DEPS_LIBS) -L$(top_builddir) -lr3 -lcheck @CHECK_LIBS@
|
AM_LDFLAGS=$(DEPS_LIBS) $(GVC_DEPS_LIBS) $(JSONC_LIBS) -L$(top_builddir) -lr3 -lcheck @CHECK_LIBS@
|
||||||
|
|
||||||
if USE_JEMALLOC
|
if USE_JEMALLOC
|
||||||
AM_CFLAGS += -ljemalloc
|
AM_CFLAGS += -ljemalloc
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
noinst_HEADERS = \
|
noinst_HEADERS = \
|
||||||
bench.h \
|
bench.h \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
|
@ -25,19 +25,19 @@ START_TEST (test_slug_compile)
|
||||||
{
|
{
|
||||||
char * path = "/user/{id}";
|
char * path = "/user/{id}";
|
||||||
char * c = NULL;
|
char * c = NULL;
|
||||||
ck_assert_str_eq( c = slug_compile(path, strlen(path) ) , "/user/([^/]+)" );
|
ck_assert_str_eq( c = slug_compile(path, strlen(path) ) , "^/user/([^/]+)" );
|
||||||
zfree(c);
|
zfree(c);
|
||||||
|
|
||||||
char * path2 = "/what/{id}-foo";
|
char * path2 = "/what/{id}-foo";
|
||||||
ck_assert_str_eq( c = slug_compile(path2, strlen(path2) ) , "/what/([^/]+)-foo" );
|
ck_assert_str_eq( c = slug_compile(path2, strlen(path2) ) , "^/what/([^/]+)-foo" );
|
||||||
zfree(c);
|
zfree(c);
|
||||||
|
|
||||||
char * path3 = "-{id}";
|
char * path3 = "-{id}";
|
||||||
ck_assert_str_eq( c = slug_compile(path3, strlen(path3)), "-([^/]+)" );
|
ck_assert_str_eq( c = slug_compile(path3, strlen(path3)), "^-([^/]+)" );
|
||||||
zfree(c);
|
zfree(c);
|
||||||
|
|
||||||
char * path4 = "-{idx:\\d{3}}";
|
char * path4 = "-{idx:\\d{3}}";
|
||||||
ck_assert_str_eq( c = slug_compile(path4, strlen(path4)), "-(\\d{3})" );
|
ck_assert_str_eq( c = slug_compile(path4, strlen(path4)), "^-(\\d{3})" );
|
||||||
zfree(c);
|
zfree(c);
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
Loading…
Reference in a new issue