diff --git a/apisix/admin/v3_adapter.lua b/apisix/admin/v3_adapter.lua index 8941eef3fde9..472f90380622 100644 --- a/apisix/admin/v3_adapter.lua +++ b/apisix/admin/v3_adapter.lua @@ -174,8 +174,8 @@ local function filter(body, args, resource) if args.label then label_matched = false if body.list[i].value.labels then - for k, _ in pairs(body.list[i].value.labels) do - if k == args.label then + for k, v in pairs(body.list[i].value.labels) do + if k == args.label or k .. ":" .. v == args.label then label_matched = true break end diff --git a/t/admin/filter.t b/t/admin/filter.t index 075af699af4a..4b14b1c2848d 100644 --- a/t/admin/filter.t +++ b/t/admin/filter.t @@ -549,6 +549,14 @@ passed res = json.decode(res) assert(#res.list == 0) + -- match labels' key and value + code, body, res = t('/apisix/admin/routes/?label=env2:production', + ngx.HTTP_GET + ) + res = json.decode(res) + assert(#res.list == 1) + assert(res.list[1].value.id == "2") + ngx.status = code ngx.say(body) }