Skip to content

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

@Kosta-Github

Description

@Kosta-Github

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)

Metadata

Metadata

Type

No type

Projects

Status

✅ Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions