Skip to content

Commit

Permalink
replace_dashes_lower
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Oct 24, 2023
1 parent a101659 commit 258cf95
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions kong/router/atc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ local get_queries_key
do
local tb_sort = table.sort
local tb_concat = table.concat
local replace_dashes = require("kong.tools.string").replace_dashes
local replace_dashes_lower = require("kong.tools.string").replace_dashes_lower

local str_buf = buffer.new(64)

Expand All @@ -571,7 +571,7 @@ do

-- NOTE: DO NOT yield until str_buf:get()
for name, value in pairs(headers) do
local name = replace_dashes(name):lower()
local name = replace_dashes_lower(name)

if type(value) == "table" then
for i, v in ipairs(value) do
Expand Down
6 changes: 3 additions & 3 deletions kong/router/compat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ local tb_nkeys = require("table.nkeys")
local uuid = require("resty.jit-uuid")


local shallow_copy = require("kong.tools.utils").shallow_copy
local replace_dashes = require("kong.tools.string").replace_dashes
local shallow_copy = require("kong.tools.utils").shallow_copy
local replace_dashes_lower = require("kong.tools.string").replace_dashes_lower


local is_regex_magic = utils.is_regex_magic
Expand Down Expand Up @@ -252,7 +252,7 @@ local function get_expression(route)
single_header_buf:reset():put("(")

for i, value in ipairs(v) do
local name = "any(http.headers." .. replace_dashes(h):lower() .. ")"
local name = "any(http.headers." .. replace_dashes_lower(h) .. ")"
local op = OP_EQUAL

-- value starts with "~*"
Expand Down
6 changes: 6 additions & 0 deletions kong/tools/string.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ local _M = {}


local replace_dashes
local replace_dashes_lower
do
local str_replace_char

Expand All @@ -31,8 +32,13 @@ do
replace_dashes = function(str)
return str_replace_char(str, "-", "_")
end

replace_dashes_lower = function(str)
return str_replace_char(str:lower(), "-", "_")
end
end
_M.replace_dashes = replace_dashes
_M.replace_dashes_lower = replace_dashes_lower


return _M
Expand Down

0 comments on commit 258cf95

Please sign in to comment.