Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ All notable changes to the Docker Language Server will be documented in this fil
- Compose
- textDocument/completion
- prevent wildcard object attribute suggestions if the text cursor is not at the right indentation for attributes to be inserted ([#342](https://github.com/docker/docker-language-server/issues/342))
- textDocument/documentLink
- fix bounds index error if a quoted string just has a registry and the colon character at the end ([#351](https://github.com/docker/docker-language-server/issues/351))

## [0.13.0] - 2025-07-09

Expand Down
18 changes: 9 additions & 9 deletions internal/compose/documentLink.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,33 +231,33 @@ func DocumentLink(ctx context.Context, documentURI protocol.URI, doc document.Co

func extractImageLink(nodeValue string) (string, string) {
if strings.HasPrefix(nodeValue, "ghcr.io") {
if len(nodeValue) <= 8 {
return "", ""
}
idx := strings.LastIndex(nodeValue, ":")
if idx == -1 {
if len(nodeValue) <= 8 {
return "", ""
}
return nodeValue, fmt.Sprintf("https://%v", nodeValue)
}
return nodeValue[0:idx], fmt.Sprintf("https://%v", nodeValue[0:idx])
}

if strings.HasPrefix(nodeValue, "mcr.microsoft.com") {
if len(nodeValue) <= 18 {
return "", ""
}
idx := strings.LastIndex(nodeValue, ":")
if idx == -1 {
if len(nodeValue) <= 18 {
return "", ""
}
return nodeValue, fmt.Sprintf("https://mcr.microsoft.com/artifact/mar/%v", nodeValue[18:])
}
return nodeValue[0:idx], fmt.Sprintf("https://mcr.microsoft.com/artifact/mar/%v", nodeValue[18:idx])
}

if strings.HasPrefix(nodeValue, "quay.io") {
if len(nodeValue) <= 8 {
return "", ""
}
idx := strings.LastIndex(nodeValue, ":")
if idx == -1 {
if len(nodeValue) <= 8 {
return "", ""
}
return nodeValue, fmt.Sprintf("https://quay.io/repository/%v", nodeValue[8:])
}
return nodeValue[0:idx], fmt.Sprintf("https://quay.io/repository/%v", nodeValue[8:idx])
Expand Down
24 changes: 24 additions & 0 deletions internal/compose/documentLink_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,14 @@ services:
image: ghcr.io:`,
links: nil,
},
{
name: "image: \"ghcr.io:\"",
content: `
services:
test:
image: "ghcr.io:"`,
links: []protocol.DocumentLink{},
},
{
name: "image: mcr.microsoft.com/powershell",
content: `
Expand Down Expand Up @@ -593,6 +601,14 @@ services:
image: mcr.microsoft.com:`,
links: nil,
},
{
name: "image: \"mcr.microsoft.com:\"",
content: `
services:
test:
image: "mcr.microsoft.com:"`,
links: []protocol.DocumentLink{},
},
{
name: "image: quay.io/prometheus/node-exporter",
content: `
Expand Down Expand Up @@ -651,6 +667,14 @@ services:
image: quay.io:`,
links: nil,
},
{
name: "image: \"quay.io:\"",
content: `
services:
test:
image: "quay.io:"`,
links: []protocol.DocumentLink{},
},
{
name: "anchors and aliases to nothing",
content: `
Expand Down
Loading