| 1 | package evidence |
| 2 | |
| 3 | import ( |
| 4 | pathpkg "path" |
| 5 | "strings" |
| 6 | ) |
| 7 | |
| 8 | // normalizeTargetPath provides stable cross-platform receipt target identities. |
| 9 | func normalizeTargetPath(value string) string { |
| 10 | value = strings.ReplaceAll(strings.TrimSpace(value), `\`, "/") |
| 11 | if value == "" { |
| 12 | return "" |
| 13 | } |
| 14 | cleaned := pathpkg.Clean(value) |
| 15 | // path.Clean treats a Windows drive prefix as an ordinary path component |
| 16 | // and removes the root slash from "C:/". Restore it so drive roots remain |
| 17 | // absolute and can safely relativize paths in cross-platform evidence. |
| 18 | if len(value) == 3 && value[1] == ':' && value[2] == '/' && len(cleaned) == 2 && cleaned[1] == ':' { |
| 19 | return cleaned + "/" |
| 20 | } |
| 21 | return cleaned |
| 22 | } |
| 23 |