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

use replaceAll() instead of replace() when turning a label into a regex #1078

Open
2 of 4 tasks
Kosta-Github opened this issue Jan 6, 2025 · 0 comments
Open
2 of 4 tasks

Comments

@Kosta-Github
Copy link

Describe the bug

replace() is only replacing the first occurrence of a string; replaceAll() should be used instead.

affected code location:

label = label.replace('.', '\\.');

Expected Behavior

if a label value contains more than one dot . all dots should be handled correctly and turned into the proper regex expression: apiVersion: some-schema/v1.0.0 -> apiVersion:[\t ]+some-schema/v1\.0\.0

Current Behavior

if a label value contains more than one dot . the generated regex does not handle the subsequent dots properly (note the missing escaping for the second dot): apiVersion: some-schema/v1.0.0 -> apiVersion:[\t ]+some-schema/v1\.0.0

Steps to Reproduce

see above

Environment

  • Windows
  • Mac
  • Linux
  • other (please specify)
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

No branches or pull requests

1 participant