IsHexString checks if a string contains only hexadecimal characters. This is used to validate Git commit SHAs and other hexadecimal identifiers.
(s string)
| 49 | // IsHexString checks if a string contains only hexadecimal characters. |
| 50 | // This is used to validate Git commit SHAs and other hexadecimal identifiers. |
| 51 | func IsHexString(s string) bool { |
| 52 | if s == "" { |
| 53 | return false |
| 54 | } |
| 55 | for _, c := range s { |
| 56 | if (c < '0' || c > '9') && (c < 'a' || c > 'f') && (c < 'A' || c > 'F') { |
| 57 | return false |
| 58 | } |
| 59 | } |
| 60 | return true |
| 61 | } |
| 62 | |
| 63 | // IsValidFullSHA checks if s is a valid 40-character lowercase hexadecimal SHA. |
| 64 | func IsValidFullSHA(s string) bool { |
no outgoing calls