This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new 1b3e547  feat: resolve var supports `${...}` format (#3320)
1b3e547 is described below

commit 1b3e547c5b041693e5a336486e9bc9f160435e53
Author: 罗泽轩 <spacewander...@gmail.com>
AuthorDate: Mon Jan 18 08:23:15 2021 -0600

    feat: resolve var supports `${...}` format (#3320)
    
    Signed-off-by: spacewander <spacewander...@gmail.com>
---
 apisix/core/utils.lua | 2 +-
 t/core/utils.t        | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/apisix/core/utils.lua b/apisix/core/utils.lua
index ab9ba0a..8629d97 100644
--- a/apisix/core/utils.lua
+++ b/apisix/core/utils.lua
@@ -255,7 +255,7 @@ _M.sleep = sleep
 local resolve_var
 do
     local _ctx
-    local pat = [[(?<!\\)\$(\w+)]]
+    local pat = [[(?<!\\)\$\{?(\w+)\}?]]
 
     local function resolve(m)
         local v = _ctx[m[1]]
diff --git a/t/core/utils.t b/t/core/utils.t
index 4006b6a..3b2acec 100644
--- a/t/core/utils.t
+++ b/t/core/utils.t
@@ -217,6 +217,9 @@ close: 1 nil}
                 "$you and $me",
                 "$eva and $me",
                 "$you and \\$me",
+                "${you}_${me}",
+                "${you}${me}",
+                "${you}$me",
             }
             local ctx = {
                 you = "John",
@@ -239,3 +242,6 @@ res:tell David to
 res:John and David
 res: and David
 res:John and \$me
+res:John_David
+res:JohnDavid
+res:JohnDavid

Reply via email to