Mercurial Hosting > d2o
changeset 13:9460f83a5664
subPath fix
| author | Atarwn Gard <a@qwa.su> |
|---|---|
| date | Mon, 23 Mar 2026 13:45:50 +0500 |
| parents | 84384cccda0e |
| children | a51dfcb0faeb |
| files | icf/icf.go |
| diffstat | 1 files changed, 12 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
diff -r 84384cccda0e -r 9460f83a5664 icf/icf.go --- a/icf/icf.go Mon Mar 23 12:05:05 2026 +0500 +++ b/icf/icf.go Mon Mar 23 13:45:50 2026 +0500 @@ -8,6 +8,7 @@ "bufio" "fmt" "io" + "path" "strings" ) @@ -187,10 +188,18 @@ return nil, nil, "" } - // rem is the unmatched suffix after the path pattern. - // Ensure it starts with "/" to form a valid absolute subpath. + // subPath is the filesystem path relative to rootDir. + // rem is the unmatched suffix after the path pattern + _, bestPatPath, bestHasPath := strings.Cut(best.block.ID, "/") subPath := best.rem - if !strings.HasPrefix(subPath, "/") { + if bestHasPath && subPath == "" { + base := path.Base(inPath) + if strings.Contains(base, ".") { + subPath = "/" + inPath + } else { + subPath = "/" + } + } else if !strings.HasPrefix(subPath, "/") { subPath = "/" + subPath } return c.ResolveBlock(best.block, best.captures), best.captures, subPath
