Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Sep 8, 2022
1 parent 58f19f5 commit d26391e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions kong/router/compat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,15 @@ local function get_expression(route)
return is_regex_magic(path) and OP_REGEX or OP_PREFIX
end, paths, function(op, p)
if op == OP_REGEX then
-- Rust only recognize form '?P<>'
return sub(p, 2):gsub("?<", "?P<")
-- 1. strip leading `~`
p = sub(p, 2)
-- 2. prefix with `^` to match the anchored behavior of the traditional router
p = "^" .. p
-- 3. update named capture opening tag for rust regex::Regex compatibility
return p:gsub("?<", "?P<")
end

return normalize(p, true)
return p
end)
if gen then
tb_insert(out, gen)
Expand Down

0 comments on commit d26391e

Please sign in to comment.