Skip to content

Commit 6177c46

Browse files
committed
Add a path attribute check before calculating document links
Signed-off-by: Remy Suen <[email protected]>
1 parent dbd0b28 commit 6177c46

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

internal/compose/documentLink.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ func scanForLinks(u *url.URL, n *ast.MappingValueNode) []protocol.DocumentLink {
7171
if sequence, ok := n.Value.(*ast.SequenceNode); ok {
7272
for _, entry := range sequence.Values {
7373
if mappingNode, ok := entry.(*ast.MappingValueNode); ok {
74+
if mappingNode.Key.GetToken().Value != "path" {
75+
continue
76+
}
7477
entry = mappingNode.Value
7578
}
7679
if sequenceNode, ok := entry.(*ast.SequenceNode); ok {

internal/compose/documentLink_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ func TestDocumentLink_IncludedFiles(t *testing.T) {
8888
},
8989
},
9090
},
91+
{
92+
name: "included files, attribute misspelt",
93+
content: `include:
94+
- path2: file.yml`,
95+
links: []protocol.DocumentLink{},
96+
},
9197
{
9298
name: "included files, mixed paths",
9399
content: `

0 commit comments

Comments
 (0)