From fbcdca00d6b0465e659a5d47914ab6fc9c3e333a Mon Sep 17 00:00:00 2001 From: Rucha0901 Date: Sun, 6 Dec 2026 10:37:38 +0530 Subject: [PATCH] fix: correct index error in `substring-after-last` Signed-off-by: Rucha0901 --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/string/substring-after-last/lib/main.js | 2 +- .../@stdlib/string/substring-after-last/test/test.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/string/substring-after-last/lib/main.js b/lib/node_modules/@stdlib/string/substring-after-last/lib/main.js index 89d1d6855dd9..787a3409cd4d 100644 --- a/lib/node_modules/@stdlib/string/substring-after-last/lib/main.js +++ b/lib/node_modules/@stdlib/string/substring-after-last/lib/main.js @@ -72,7 +72,7 @@ function substringAfterLast( str, search, fromIndex ) { } if ( arguments.length > 2 ) { if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%s`.', fromIndex ) ); + throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', fromIndex ) ); } idx = str.lastIndexOf( search, fromIndex ); } else { diff --git a/lib/node_modules/@stdlib/string/substring-after-last/test/test.js b/lib/node_modules/@stdlib/string/substring-after-last/test/test.js index a14b06581f8d..4968d710a196 100644 --- a/lib/node_modules/@stdlib/string/substring-after-last/test/test.js +++ b/lib/node_modules/@stdlib/string/substring-after-last/test/test.js @@ -88,6 +88,15 @@ tape( 'the function throws an error if not provided a string as its second argum } }); +tape( 'the function throws an error if the start index is not an integer', function test( t ) { + t.throws( badValue, /Third argument must be an integer\./, 'reports that the start index must be an integer' ); + t.end(); + + function badValue() { + substringAfterLast( 'beep', 'b', -1.5 ); + } +}); + tape( 'the function returns the substring after the last occurrence of a provided search string', function test( t ) { var expected; var actual;