isFilePath checks if the identifier is a file path
(identifier string)
| 725 | |
| 726 | // isFilePath checks if the identifier is a file path |
| 727 | func isFilePath(identifier string) bool { |
| 728 | // If it contains @ or :, it's likely an image reference, not a file |
| 729 | if strings.Contains(identifier, "@") || strings.Contains(identifier, ":") { |
| 730 | return false |
| 731 | } |
| 732 | |
| 733 | // Check if it's an absolute path |
| 734 | if filepath.IsAbs(identifier) { |
| 735 | return true |
| 736 | } |
| 737 | |
| 738 | // Check if it's a relative path (./ or ../) |
| 739 | if strings.HasPrefix(identifier, "./") || strings.HasPrefix(identifier, "../") { |
| 740 | return true |
| 741 | } |
| 742 | |
| 743 | // Check if it's a relative path that exists |
| 744 | if _, err := os.Stat(identifier); err == nil { |
| 745 | return true |
| 746 | } |
| 747 | |
| 748 | // Check if it looks like a file path (contains path separators) |
| 749 | if strings.Contains(identifier, "/") || strings.Contains(identifier, "\\") { |
| 750 | return true |
| 751 | } |
| 752 | |
| 753 | // Check if it has a file extension |
| 754 | if filepath.Ext(identifier) != "" { |
| 755 | return true |
| 756 | } |
| 757 | |
| 758 | // If it doesn't look like a file path and doesn't contain special characters, |
| 759 | // it might be a simple filename, but we need to be more careful |
| 760 | return false |
| 761 | } |
| 762 | |
| 763 | // DetectIdentifierType detects the type of VSA identifier |
| 764 | func DetectIdentifierType(identifier string) IdentifierType { |
no outgoing calls