From 02265331d49575180c87a203d1045bad1e9b0833 Mon Sep 17 00:00:00 2001 From: xfy Date: Mon, 27 Apr 2026 13:28:25 +0800 Subject: [PATCH] =?UTF-8?q?fix(converter):=20=E6=B2=A1=E6=9C=89=20root/ali?= =?UTF-8?q?as/try=5Ffiles=20=E7=9A=84=20location=20=E7=BB=A7=E6=89=BF=20se?= =?UTF-8?q?rver=20root?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - classifyLocation 增加 serverRoot 参数 - 当 location 没有显式 root/alias/try_files 但有 server 级别 root 时,分类为 static - 正则 location 正确继承 server root 并设置 location_type Co-Authored-By: Claude Opus 4.7 --- internal/converter/nginx/converter.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/internal/converter/nginx/converter.go b/internal/converter/nginx/converter.go index 31416c1..29a049f 100644 --- a/internal/converter/nginx/converter.go +++ b/internal/converter/nginx/converter.go @@ -254,7 +254,7 @@ func convertServerBlock(d *Directive, upstreams map[string]*upstreamInfo, result case "rewrite": parseRewrite(bd, &server) case "location": - classification := classifyLocation(bd, result) + classification := classifyLocation(bd, serverRoot, result) convertLocation(classification, &server, upstreams, result) case "error_page": parseErrorPage(bd, &server) @@ -506,7 +506,7 @@ func parseAuthBasic(d *Directive, server *config.ServerConfig) { } // classifyLocation classifies a location block based on its directives. -func classifyLocation(d *Directive, result *ConvertResult) locationClassification { +func classifyLocation(d *Directive, serverRoot string, result *ConvertResult) locationClassification { class := locationClassification{ Directives: d.Block, } @@ -570,7 +570,13 @@ func classifyLocation(d *Directive, result *ConvertResult) locationClassificatio case hasRedirect: class.LocType = redirectType default: - class.LocType = "unsupported" + // If no explicit root/alias/try_files but server-level root exists, + // classify as static (will inherit server root) + if serverRoot != "" { + class.LocType = "static" + } else { + class.LocType = "unsupported" + } } return class