Skip to content

Commit

Permalink
hotfix(parse): do not reuse key to try transformed for previous source
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Mar 26, 2024
1 parent 021e75a commit 4920427
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions internal/parse/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ func get(sources []Source, key string, options ...Option) (
keysToTry = append(keysToTry, key)

var firstKeySet string
var firstSource Source

for _, keyToTry := range keysToTry {
for _, sourceToTry := range sources {
keyToTry = sourceToTry.KeyTransform(keyToTry)
stringValue, isSet := sourceToTry.Get(keyToTry)
transformedKeyToTry := sourceToTry.KeyTransform(keyToTry)
stringValue, isSet := sourceToTry.Get(transformedKeyToTry)
if !isSet {
continue
}
firstKeySet = keyToTry
key = sourceToTry.KeyTransform(key)
sourceKind = sourceToTry.String()
firstKeySet = transformedKeyToTry
firstSource = sourceToTry
value = new(string)
*value = stringValue
break
Expand All @@ -59,8 +59,11 @@ func get(sources []Source, key string, options ...Option) (
return nil, ""
}

key = firstSource.KeyTransform(key)
sourceKind = firstSource.String()
if settings.currentKey != "" { // all keys are retro-compatible keys
settings.handleDeprecatedKey(sourceKind, firstKeySet, settings.currentKey)
currentKey := firstSource.KeyTransform(settings.currentKey)
settings.handleDeprecatedKey(sourceKind, firstKeySet, currentKey)
} else if firstKeySet != key {
settings.handleDeprecatedKey(sourceKind, firstKeySet, key)
}
Expand Down

0 comments on commit 4920427

Please sign in to comment.