feat: supports importValue for more path formats (#1569)

`importValueRegex` now can match more path formats

Resolves: #1568
This commit is contained in:
Fyn
2022-02-25 11:16:57 +08:00
committed by GitHub
parent e0454138e0
commit db949e40f1
3 changed files with 28 additions and 4 deletions

View File

@@ -114,13 +114,16 @@ func (p *Parser) parse(filename, content string) (*Api, error) {
apiAstList = append(apiAstList, root)
for _, imp := range root.Import {
dir := filepath.Dir(p.src)
imp := filepath.Join(dir, imp.Value.Text())
data, err := p.readContent(imp)
impPath := strings.ReplaceAll(imp.Value.Text(), "\"", "")
if !filepath.IsAbs(impPath) {
impPath = filepath.Join(dir, impPath)
}
data, err := p.readContent(impPath)
if err != nil {
return nil, err
}
nestedApi, err := p.invoke(imp, data)
nestedApi, err := p.invoke(impPath, data)
if err != nil {
return nil, err
}