Skip to content

Commit

Permalink
transplant #9451
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Sep 21, 2022
1 parent 851889b commit c8d5bf8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 8 additions & 1 deletion kong/router/atc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ local lrucache = require("resty.lrucache")
local server_name = require("ngx.ssl").server_name
local tb_new = require("table.new")
local tb_clear = require("table.clear")
local isempty = require("table.isempty")
local utils = require("kong.router.utils")
local yield = require("kong.tools.utils").yield

Expand Down Expand Up @@ -80,8 +81,13 @@ local function escape_str(str)
end


local function is_empty_field(f)
return f == nil or f == null or isempty(f)
end


local function gen_for_field(name, op, vals, val_transform)
if not vals or vals == null then
if is_empty_field(vals) then
return nil
end

Expand Down Expand Up @@ -520,6 +526,7 @@ end


_M.escape_str = escape_str
_M.is_empty_field = is_empty_field
_M.gen_for_field = gen_for_field
_M.split_host_port = split_host_port

Expand Down
5 changes: 3 additions & 2 deletions kong/router/compat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ local tb_nkeys = require("table.nkeys")


local escape_str = atc.escape_str
local is_empty_field = atc.is_empty_field
local gen_for_field = atc.gen_for_field
local split_host_port = atc.split_host_port

Expand Down Expand Up @@ -76,7 +77,7 @@ local function get_expression(route)
tb_insert(out, gen)
end

if hosts and hosts ~= null then
if not is_empty_field(hosts) then
tb_clear(exp_hosts_t)
local hosts_t = exp_hosts_t

Expand Down Expand Up @@ -133,7 +134,7 @@ local function get_expression(route)
tb_insert(out, gen)
end

if headers and headers ~= null then
if not is_empty_field(headers) then
tb_clear(exp_headers_t)
local headers_t = exp_headers_t

Expand Down

0 comments on commit c8d5bf8

Please sign in to comment.