fix(filters): empty result when capture-group replace does not match - #937
Open
sankalpsthakur wants to merge 1 commit into
Open
fix(filters): empty result when capture-group replace does not match#937sankalpsthakur wants to merge 1 commit into
sankalpsthakur wants to merge 1 commit into
Conversation
…atch When replace uses $1/$2-style group references and the regex does not match, String.replace previously returned the original input. Clipper templates that extract a field via groups then expect "" (Fixes obsidianmd#589). Signed-off-by: Sankalp Thakur <sankalphimself@gmail.com>
sankalpsthakur
force-pushed
the
fix/589-replace-empty-group
branch
from
September 4, 2026 03:21
d221067 to
4d1cab8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When replace uses capture groups like $1 and the regex does not match, JS String.replace returns the original string. Template extractors then dump full page text into the field.
If the replacement references groups and there is no match, return empty string instead. Literal replacements (no $n) keep existing no-match behavior.
Validation
Fixes #589
AI disclosure
AI tools helped draft code and this description. I reviewed the change and ran the tests above before submitting.