d2parser: Strip leading ./ from imports
This commit is contained in:
parent
bc8f180055
commit
0300b81c31
2 changed files with 15 additions and 0 deletions
|
|
@ -633,6 +633,14 @@ x: @file.d2
|
|||
x: @file."d2"
|
||||
`,
|
||||
exp: `x: @file."d2"
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "import/3",
|
||||
in: `
|
||||
x: @./file
|
||||
`,
|
||||
exp: `x: @file
|
||||
`,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1720,6 +1720,13 @@ func (p *parser) parseImport(spread bool) *d2ast.Import {
|
|||
imp.Range.Start = imp.Range.Start.SubtractString("...", p.utf16)
|
||||
}
|
||||
|
||||
s, eof := p.peekn(2)
|
||||
if eof || s != "./" {
|
||||
p.rewind()
|
||||
} else {
|
||||
p.commit()
|
||||
}
|
||||
|
||||
k := p.parseKey()
|
||||
if k == nil {
|
||||
return imp
|
||||
|
|
|
|||
Loading…
Reference in a new issue