Skip to content

Commit

Permalink
feat: support '.' in id definition (#2795)
Browse files Browse the repository at this point in the history
* feat: support '.' in id definition

Close #2274.

* tweak test
  • Loading branch information
spacewander authored Nov 23, 2020
1 parent 2649d1c commit d7593a0
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apisix/schema_def.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ local id_schema = {
anyOf = {
{
type = "string", minLength = 1, maxLength = 64,
pattern = [[^[a-zA-Z0-9-_]+$]]
pattern = [[^[a-zA-Z0-9-_.]+$]]
},
{type = "integer", minimum = 1}
}
Expand Down
46 changes: 46 additions & 0 deletions t/admin/services.t
Original file line number Diff line number Diff line change
Expand Up @@ -1441,3 +1441,49 @@ GET /t
{"error_msg":"invalid configuration: property \"name\" validation failed: string too long, expected at most 100, got 101"}
--- no_error_log
[error]



=== TEST 39: allow dot in the id
--- config
location /t {
content_by_lua_block {
local t = require("lib.test_admin").test
local code, body = t('/apisix/admin/services/a.b',
ngx.HTTP_PUT,
[[{
"upstream": {
"nodes": {
"127.0.0.1:8080": 1
},
"type": "roundrobin"
},
"desc": "new service"
}]],
[[{
"node": {
"value": {
"upstream": {
"nodes": {
"127.0.0.1:8080": 1
},
"type": "roundrobin"
},
"desc": "new service"
},
"key": "/apisix/services/a.b"
},
"action": "set"
}]]
)

ngx.status = code
ngx.say(body)
}
}
--- request
GET /t
--- response_body
passed
--- no_error_log
[error]

0 comments on commit d7593a0

Please sign in to comment.