Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix blank replacement on relabel matches fixes #363 #391

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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

codeclimate bot commented Aug 14, 2024

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