fengxsong commented on code in PR #9194:
URL: https://github.com/apache/apisix/pull/9194#discussion_r1165199597


##########
apisix/plugins/proxy-rewrite.lua:
##########
@@ -281,25 +288,36 @@ function _M.rewrite(conf, ctx)
         if not str_find(upstream_uri, "?") then
             separator_escaped = true
         end
-
-        local uri, _, err = re_sub(upstream_uri, conf.regex_uri[1],
-                                   conf.regex_uri[2], "jo")
-        if not uri then
-            local msg = "failed to substitute the uri " .. ctx.var.uri ..
-                        " (" .. conf.regex_uri[1] .. ") with " ..
-                        conf.regex_uri[2] .. " : " .. err
-            core.log.error(msg)
-            return 500, {message = msg}
+        local error_msg
+        for i = 1, #conf.regex_uri, 2 do
+            local captures, err = re_match(upstream_uri, conf.regex_uri[i], 
"jo")

Review Comment:
   > Why not do substitution directly? If successful, then break.
   
   variable `ctx.proxy_rewrite_regex_uri_captures` will be used later modifying 
request headers.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to