Ensure encoded paths are handled in lookup. #84

This partially resolves a whacky path ref lookup in the index mentioned in #84, but it's not a full fix, that requires the build out of a resolved spec. The design needs thought and care.
This commit is contained in:
Dave Shanley
2023-02-22 06:49:59 -05:00
parent 696e810ec7
commit d8a7b6c21d
2 changed files with 13 additions and 4 deletions

View File

@@ -247,6 +247,19 @@ func (index *SpecIndex) lookupFileReference(ref string) (*yaml.Node, *yaml.Node,
func (index *SpecIndex) FindComponentInRoot(componentId string) *Reference {
if index.root != nil {
// check component for url encoding.
if strings.Contains(componentId, "%") {
// decode the url.
var err error
componentId, err = url.QueryUnescape(componentId)
if err != nil {
// TODO: this is a fatal problem.
// we need some logging or something in here.
return nil
}
}
name, friendlySearch := utils.ConvertComponentIdIntoFriendlyPathSearch(componentId)
path, err := yamlpath.NewPath(friendlySearch)
if path == nil || err != nil {