MCPcopy Create free account
hub / github.com/docker/docker-language-server / extractModelLink

Function extractModelLink

internal/compose/documentLink.go:415–441  ·  view source on GitHub ↗
(nodeValue string)

Source from the content-addressed store, hash-verified

413}
414
415func 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}

Callers 1

createModelLinkFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected