[优化] 更新 Lua 包路径检查逻辑以避免重复添加

This commit is contained in:
ryan
2026-05-31 21:17:36 +08:00
parent 14d41ad807
commit 80dd5f8b31
4 changed files with 8 additions and 6 deletions
@@ -1025,7 +1025,7 @@ func TestPublishConfigVersionDetectsPoWChanges(t *testing.T) {
if !strings.Contains(secondRelease.Version.RenderedConfig, "application/javascript js mjs;") {
t.Fatal("expected rendered config to serve Anubis module scripts with a JavaScript MIME type")
}
if !strings.Contains(secondRelease.Version.RenderedConfig, " package.path = \"__OPENFLARE_LUA_DIR__/?.lua;__OPENFLARE_LUA_DIR__/?/init.lua;\" .. package.path\n require(\"waf.runtime\").check()\n if ngx.ctx.openflare_waf_blocked then\n return\n end\n require(\"pow.runtime\").check()") {
if !strings.Contains(secondRelease.Version.RenderedConfig, " if not string.find(package.path, \"__OPENFLARE_LUA_DIR__/?.lua\", 1, true) then\n package.path = \"__OPENFLARE_LUA_DIR__/?.lua;__OPENFLARE_LUA_DIR__/?/init.lua;\" .. package.path\n end\n require(\"waf.runtime\").check()\n if ngx.ctx.openflare_waf_blocked then\n return\n end\n require(\"pow.runtime\").check()") {
t.Fatal("expected combined WAF and PoW access handler to short-circuit before PoW")
}
locationStart := strings.Index(secondRelease.Version.RenderedConfig, " location / {\n")