tighten if-else and add empty skylink protection
This commit is contained in:
parent
9b09f9ba5c
commit
48b1f0d067
|
@ -159,9 +159,7 @@ server {
|
|||
if skylink == nil then
|
||||
skylink, skylink_rest = string.match(hnsres_json.skylink, "/?([^/?]+)(.*)")
|
||||
end
|
||||
end
|
||||
|
||||
if hnsres_json.registry then
|
||||
elseif hnsres_json.registry then
|
||||
local publickey = hnsres_json.registry.publickey
|
||||
local datakey = hnsres_json.registry.datakey
|
||||
|
||||
|
@ -183,6 +181,11 @@ server {
|
|||
skylink = data
|
||||
end
|
||||
|
||||
-- fail with a generic 404 if skylink has not been extracted from a valid /hnsres response for some reason
|
||||
if not skylink then
|
||||
ngx.exit(ngx.HTTP_NOT_FOUND)
|
||||
end
|
||||
|
||||
ngx.var.skylink = skylink
|
||||
if request_uri_rest == "/" and skylink_rest ~= "" and skylink_rest ~= "/" then
|
||||
ngx.var.rest = skylink_rest
|
||||
|
|
Reference in New Issue