Skip to content

Conversation

crystalstorm
Copy link

This will fix the relabeling issues reported here #363 and here #377

if len(r.Matches) > 0 {
	replacement := ""
	for i := range r.Matches {
		if r.Matches[i].CompiledRegexp.MatchString(sourceValue) {
			replacement = r.Matches[i].CompiledRegexp.ReplaceAllString(sourceValue, r.Matches[i].Replacement)
			break
		}
	}
	sourceValue = replacement
}

The current logic is flawed, because in the case where there are Matches but the Regexp does NOT match the sourceValue
the sourceValue still gets replaced with ""

Copy link

Code Climate has analyzed commit 93469d5 and detected 0 issues on this pull request.

View more on Code Climate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant