ruanweihong-aaa opened a new pull request, #13800:
URL: https://github.com/apache/apisix/pull/13800

   ### Description
   
   Currently, `proxy-rewrite.uri` supports NGINX variables, but the replacement 
part of `proxy-rewrite.regex_uri` only supports regular expression captures 
such as `$1` and `$2`.
   
   This PR adds NGINX variable resolution support to `regex_uri` replacements.
   
   For example:
   
   ```json
   {
     "regex_uri": [
       "^/api/(.*)/users/(.*)$",
       "/v2/$1/external-users/$arg_name"
     ]
   }
   ```
   
   The replacement is processed in explicit stages:
   
   1. Preserve literal dollar expressions such as `$$x`.
   2. Resolve regular expression captures such as `$1` and `$2`.
   3. Resolve NGINX variables such as `$arg_name` and variables stored in 
`ctx.var`.
   4. Restore literal dollar expressions.
   
   Schema validation also distinguishes NGINX variables from regular expression 
captures. This allows a route containing both forms to be saved successfully.
   
   Existing `$1` and `$2` capture behavior and `$$` literal-dollar behavior 
remain compatible.
   
   The English and Chinese `proxy-rewrite` documentation have also been updated 
to describe the new behavior.
   
   #### Which issue(s) this PR fixes:
   
   Fixes #13140
   
   ### Tests
   
   - Added `t/plugin/proxy-rewrite4.t`.
   - Verified regular expression captures and NGINX variables in the same 
replacement.
   - Verified existing `$1` and `$2` capture behavior.
   - Verified literal `$$x` behavior.
   - `t/plugin/proxy-rewrite4.t`: 6/6 passed.
   - `luacheck`: 0 warnings and 0 errors for the modified Lua file.
   - `lj-releng`: passed for the modified Lua file.
   - Source-matched Docker BEFORE/AFTER verification: all six checks passed.
   
   ### Checklist
   
   - [x] I have explained the need for this PR and the problem it solves
   - [x] I have explained the changes or the new features added to this PR
   - [x] I have added tests corresponding to this change
   - [x] I have updated the documentation to reflect this change
   - [x] I have verified that this change is backward compatible


-- 
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