Commit 4af406bc authored by François Perrad's avatar François Perrad
Browse files

fix consecutive {.var}

parent 961287c2
Pipeline #156446 passed with stages
in 20 seconds
......@@ -246,7 +246,7 @@ local function match (s, ops)
c = s:sub(i, i)
if c == sep_var[oper] then
capture[varname] = unescape(s:sub(start, i-1), query)
if oper == '/' and not op[nvar+1] then
if (oper == '/' or oper == '.') and not op[nvar+1] then
break
else
nvar = nvar + 1
......
......@@ -18,7 +18,7 @@ local function kv_is (t, k, expected, name)
end
end
plan(209)
plan(221)
local ctor = require 'Silva.template'
......@@ -165,6 +165,17 @@ capture = sme('/foo.1024.')
kv_is( capture, 'x', '1024' )
kv_is( capture, 'y', '' )
sme = ctor'/foo{.x}{.y}'
capture = sme('/foo.1024.768')
kv_is( capture, 'x', '1024' )
kv_is( capture, 'y', '768' )
capture = sme('/foo.1024')
kv_is( capture, 'x', '1024' )
kv_is( capture, 'y', nil )
capture = sme('/foo.1024.')
kv_is( capture, 'x', '1024' )
kv_is( capture, 'y', '' )
sme = ctor'/foo{.x,y}bar'
capture = sme('/foo.1024.768bar')
kv_is( capture, 'x', '1024' )
......@@ -176,6 +187,17 @@ capture = sme('/foo.1024.bar')
kv_is( capture, 'x', '1024' )
kv_is( capture, 'y', '' )
sme = ctor'/foo{.x}{.y}bar'
capture = sme('/foo.1024.768bar')
kv_is( capture, 'x', '1024' )
kv_is( capture, 'y', '768' )
capture = sme('/foo.1024bar')
kv_is( capture, 'x', '1024' )
kv_is( capture, 'y', nil )
capture = sme('/foo.1024.bar')
kv_is( capture, 'x', '1024' )
kv_is( capture, 'y', '' )
sme = ctor'/foo{/var}'
capture = sme('/foo/bar')
kv_is( capture, 'var', 'bar' )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment