MCPcopy Create free account
hub / github.com/conforma/cli / isFilePath

Function isFilePath

internal/validate/vsa/vsa.go:727–761  ·  view source on GitHub ↗

isFilePath checks if the identifier is a file path

(identifier string)

Source from the content-addressed store, hash-verified

725
726// isFilePath checks if the identifier is a file path
727func 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
764func DetectIdentifierType(identifier string) IdentifierType {

Callers 2

DetectIdentifierTypeFunction · 0.85
TestIsFilePathFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestIsFilePathFunction · 0.68