Skip to content

fix: ensure support for empty replacement strings - #16553

Merged
kgryte merged 3 commits into
stdlib-js:developfrom
autistic-avenger:replacement-fixes
Nov 10, 2026
Merged

kgryte merged 3 commits into
stdlib-js:developfrom
autistic-avenger:replacement-fixes

Conversation

@autistic-avenger

Copy link
Copy Markdown
Contributor

Resolves #16547

Description

This pull request:

Fixes the issue where replaceAfter, replaceAfterLast, replaceBefore, and replaceBeforeLast functions were not handling Empty strings "" ,Instead of replacing the matched part with an empty string they were returning the entire String.

Related Issues

NOPE

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

I asked ai to write the test cases for my changes and proof read once so i don't miss any function still containing the bug I'm trying to fix.


@stdlib-js/reviewers

@autistic-avenger
autistic-avenger requested a review from a team November 9, 2026 10:01
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Nov 9, 2026

@kgryte kgryte left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for fixing!

@kgryte kgryte added Bug Something isn't working. difficulty: 2 May require some initial design or R&D, but should be straightforward to resolve and/or implement. review: 5 and removed Needs Review A pull request which needs code review. labels Nov 10, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
string/base/replace-after $\\color{green}124/124$
$\\color{green}+100.00\\%$
$\\color{green}10/10$
$\\color{green}+100.00\\%$
$\\color{green}1/1$
$\\color{green}+100.00\\%$
$\\color{green}124/124$
$\\color{green}+100.00\\%$
string/base/replace-after-last $\\color{green}125/125$
$\\color{green}+100.00\\%$
$\\color{green}9/9$
$\\color{green}+100.00\\%$
$\\color{green}1/1$
$\\color{green}+100.00\\%$
$\\color{green}125/125$
$\\color{green}+100.00\\%$
string/base/replace-before $\\color{green}108/108$
$\\color{green}+100.00\\%$
$\\color{green}10/10$
$\\color{green}+100.00\\%$
$\\color{green}1/1$
$\\color{green}+100.00\\%$
$\\color{green}108/108$
$\\color{green}+100.00\\%$
string/base/replace-before-last $\\color{green}125/125$
$\\color{green}+100.00\\%$
$\\color{green}9/9$
$\\color{green}+100.00\\%$
$\\color{green}1/1$
$\\color{green}+100.00\\%$
$\\color{green}125/125$
$\\color{green}+100.00\\%$
string/replace-before $\\color{green}118/118$
$\\color{green}+100.00\\%$
$\\color{green}9/9$
$\\color{green}+100.00\\%$
$\\color{green}1/1$
$\\color{green}+100.00\\%$
$\\color{green}118/118$
$\\color{green}+100.00\\%$

The above coverage report was generated for the changes in this PR.

@kgryte kgryte changed the title fix: make the string replace functions handle Empty replacement strings fix: ensure support for empty replacement strings Nov 10, 2026
@kgryte
kgryte merged commit 4c83379 into stdlib-js:develop Nov 10, 2026
60 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working. difficulty: 2 May require some initial design or R&D, but should be straightforward to resolve and/or implement. review: 5

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Empty replacement strings are ignored in string replacement functions

3 participants