matchFullUUID checks if name starts with a full UUID (8-4-4-4-12 hex pattern). Returns the UUID, remaining slug, and whether it matched.
(name string)
| 201 | // matchFullUUID checks if name starts with a full UUID (8-4-4-4-12 hex pattern). |
| 202 | // Returns the UUID, remaining slug, and whether it matched. |
| 203 | func matchFullUUID(name string) (id, slug string, ok bool) { |
| 204 | // Full UUID is 36 chars: 8-4-4-4-12 with hyphens |
| 205 | // Minimum filename: UUID alone (36 chars) or UUID-slug (37+ chars) |
| 206 | if len(name) < 36 { |
| 207 | return "", "", false |
| 208 | } |
| 209 | |
| 210 | segments := []int{8, 4, 4, 4, 12} |
| 211 | pos := 0 |
| 212 | for i, segLen := range segments { |
| 213 | if i > 0 { |
| 214 | if pos >= len(name) || name[pos] != '-' { |
| 215 | return "", "", false |
| 216 | } |
| 217 | pos++ |
| 218 | } |
| 219 | end := pos + segLen |
| 220 | if end > len(name) { |
| 221 | return "", "", false |
| 222 | } |
| 223 | if !isHexString(name[pos:end]) { |
| 224 | return "", "", false |
| 225 | } |
| 226 | pos = end |
| 227 | } |
| 228 | |
| 229 | uuid := name[:pos] |
| 230 | rest := "" |
| 231 | if pos < len(name) { |
| 232 | if name[pos] != '-' { |
| 233 | return "", "", false |
| 234 | } |
| 235 | rest = name[pos+1:] |
| 236 | } |
| 237 | return uuid, rest, true |
| 238 | } |
| 239 | |
| 240 | // isHexID returns true if s is 9-32 lowercase hex chars. |
| 241 | // This catches truncated UUIDs longer than what isAlphanumericID handles (max 8). |
no test coverage detected