diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2018-12-08 12:03:40 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2018-12-08 12:03:40 +0200 |
commit | 602f4d93070ac0e762e0cbe3ef72ba792f9c4811 (patch) | |
tree | 8047168c6b23de38973b494b6ec794a81faf3576 /doc/vmod-dbrw.texi | |
parent | 2a684f1cdd7723c2ded277ea2c7e66227b6f3ae1 (diff) | |
download | vmod-dbrw-602f4d93070ac0e762e0cbe3ef72ba792f9c4811.tar.gz vmod-dbrw-602f4d93070ac0e762e0cbe3ef72ba792f9c4811.tar.bz2 |
Implement the $(urlprefixes) built-in function.
* NEWS: Update.
* README: Update.
* configure.ac: Version 2.2.91
* doc/vmod-dbrw.3: Document the use of $(urlprefixes) built-in
* doc/vmod-dbrw.texi: Likewise.
* src/vmod_dbrw.c (parse_flags): Make sure status string is null-terminated.
(do_rewrite): Expand built-in functions in $(). Support urlprefixes.
On debug_level=100, produce detailed trace of expansions.
* src/wordsplit.c: Pull from grecs commit 9097d529.
* src/wordsplit.h: Likewise.
* tests/initdb.at (rewrite): Change the url column.
* tests/rewrite01.at: Use $(urlprefixes) in the SQL templates.
* tests/rewrite02.at: Likewise.
* tests/rewrite03.at: Likewise.
* tests/rewrite04.at: Likewise.
* tests/rewrite05.at: Likewise.
* tests/rewrite06.at: Likewise.
Diffstat (limited to 'doc/vmod-dbrw.texi')
-rw-r--r-- | doc/vmod-dbrw.texi | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/doc/vmod-dbrw.texi b/doc/vmod-dbrw.texi index 40fc84d..31b15d1 100644 --- a/doc/vmod-dbrw.texi +++ b/doc/vmod-dbrw.texi @@ -493,25 +493,35 @@ WHERE host='$host' AND LOCATE(url,'$url')==1 ORDER BY weight @end group @end example @noindent -Furthermore, the @code{url} column can contain a SQL wildcard pattern, -in which case the query will look like: +Furthermore, the @code{url} column can contain a path prefix, +which can be matched using the @code{IN} conditional: @example @group SELECT dest,pattern,value,flags FROM rewrite WHERE host='$host' -AND '$url' like $url +AND url IN ($(urlprefixes $url)) ORDER BY weight @end group @end example +Notice the use of the @samp{$(urlprefixes $url)}. This invokes the built-in +@dfn{function} @code{urlprefixes}, which expands to comma-separated +list of properly quoted pathname prefixes, constructed from its +argument. For example, if @samp{$url} is @samp{/local/user/local?a=1}, +then the expansion of @samp{$(urlprefixes $url)} is: + +@example +'/local/user/local','/local/user','/local' +@end example + @node Rewrite @chapter The @code{rewrite} Function @deftypefn {function} string rewrite (string @var{args}) This function is the working horse of the module. It rewrites its argument using the database configured in the previous call to |