Skip to content

Improve robustness by checking for search & replace keys.#9

Open
lukesrw wants to merge 1 commit intomaxeonyx:mainfrom
lukesrw:main
Open

Improve robustness by checking for search & replace keys.#9
lukesrw wants to merge 1 commit intomaxeonyx:mainfrom
lukesrw:main

Conversation

@lukesrw
Copy link

@lukesrw lukesrw commented Nov 29, 2025

Currently if you omit the search key from ReplacementConfig this isn't caught and leads to the undesired behaviour of replacing every character in the file with the replace key.

In addition if you omit the replace key from ReplacementConfig this instead results in replacing any search matches with the string "undefined" instead of either doing nothing or replacing with an empty string (which, for the sake of this patch, I've assumed would likely be the desired behaviour?).

This patch does the following:

  • Update the ReplacementConfig interface to set search and replace keys to potentially be undefined
  • Update the applicableReplacements loop to warn and skip replacements with undefined search keys
  • Update the text replace with a nullish coalese to an empty string if replace is undefined

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