Mercurial Hosting > d2o
comparison icf/icf.go @ 13:9460f83a5664
subPath fix
| author | Atarwn Gard <a@qwa.su> |
|---|---|
| date | Mon, 23 Mar 2026 13:45:50 +0500 |
| parents | 84384cccda0e |
| children | a51dfcb0faeb |
comparison
equal
deleted
inserted
replaced
| 12:84384cccda0e | 13:9460f83a5664 |
|---|---|
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bufio" | 8 "bufio" |
| 9 "fmt" | 9 "fmt" |
| 10 "io" | 10 "io" |
| 11 "path" | |
| 11 "strings" | 12 "strings" |
| 12 ) | 13 ) |
| 13 | 14 |
| 14 type Directive struct { | 15 type Directive struct { |
| 15 Key string | 16 Key string |
| 185 | 186 |
| 186 if best == nil { | 187 if best == nil { |
| 187 return nil, nil, "" | 188 return nil, nil, "" |
| 188 } | 189 } |
| 189 | 190 |
| 190 // rem is the unmatched suffix after the path pattern. | 191 // subPath is the filesystem path relative to rootDir. |
| 191 // Ensure it starts with "/" to form a valid absolute subpath. | 192 // rem is the unmatched suffix after the path pattern |
| 193 _, bestPatPath, bestHasPath := strings.Cut(best.block.ID, "/") | |
| 192 subPath := best.rem | 194 subPath := best.rem |
| 193 if !strings.HasPrefix(subPath, "/") { | 195 if bestHasPath && subPath == "" { |
| 196 base := path.Base(inPath) | |
| 197 if strings.Contains(base, ".") { | |
| 198 subPath = "/" + inPath | |
| 199 } else { | |
| 200 subPath = "/" | |
| 201 } | |
| 202 } else if !strings.HasPrefix(subPath, "/") { | |
| 194 subPath = "/" + subPath | 203 subPath = "/" + subPath |
| 195 } | 204 } |
| 196 return c.ResolveBlock(best.block, best.captures), best.captures, subPath | 205 return c.ResolveBlock(best.block, best.captures), best.captures, subPath |
| 197 } | 206 } |
| 198 | 207 |
