| 413 | } |
| 414 | |
| 415 | func extractModelLink(nodeValue string) (string, string) { |
| 416 | if strings.HasPrefix(nodeValue, "hf.co") { |
| 417 | if len(nodeValue) <= 6 { |
| 418 | return "", "" |
| 419 | } |
| 420 | idx := strings.LastIndex(nodeValue, ":") |
| 421 | if idx == -1 { |
| 422 | return nodeValue, fmt.Sprintf("https://%v", nodeValue) |
| 423 | } |
| 424 | return nodeValue[0:idx], fmt.Sprintf("https://%v", nodeValue[0:idx]) |
| 425 | } |
| 426 | |
| 427 | idx := strings.LastIndex(nodeValue, ":") |
| 428 | if idx == -1 { |
| 429 | idx := strings.Index(nodeValue, "/") |
| 430 | if idx == -1 { |
| 431 | return nodeValue, fmt.Sprintf("https://hub.docker.com/_/%v", nodeValue) |
| 432 | } |
| 433 | return nodeValue, fmt.Sprintf("https://hub.docker.com/r/%v", nodeValue) |
| 434 | } |
| 435 | |
| 436 | slashIndex := strings.Index(nodeValue, "/") |
| 437 | if slashIndex == -1 { |
| 438 | return nodeValue[0:idx], fmt.Sprintf("https://hub.docker.com/_/%v", nodeValue[0:idx]) |
| 439 | } |
| 440 | return nodeValue[0:idx], fmt.Sprintf("https://hub.docker.com/r/%v", nodeValue[0:idx]) |
| 441 | } |