Skip to content

Commit 2a4db1d

Browse files
committed
[sc-12720] Resolve SonarCloud issue: Strings should use "replaceAll()" instead of "replace()" with global regex
1 parent 32f1908 commit 2a4db1d

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/apifetch.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export interface ApiFetchCallback<T = any> {
5252

5353
interface SourceDocuments {
5454
page: number;
55-
hits: Document[];
55+
hits: SearchResponseDocument[];
5656
total_hits: number;
5757
}
5858

@@ -141,8 +141,11 @@ const executeApiFetch: ExecuteApiFetch = function (
141141

142142
// Boolean operators (AND, OR, NOT) uppercase
143143
keyword = settings?.enableLogicalOperators
144-
? keyword.replace(/ and /g, ' AND ').replace(/ or /g, ' OR ').replace(/ not /g, ' NOT ')
145-
: keyword.replace(/ AND /g, ' and ').replace(/ OR /g, ' or ').replace(/ NOT /g, ' not ');
144+
? keyword.replaceAll(' and ', ' AND ').replaceAll(' or ', ' OR ').replaceAll(' not ', ' NOT ')
145+
: keyword
146+
.replaceAll(' AND ', ' and ')
147+
.replaceAll(' OR ', ' or ')
148+
.replaceAll(' NOT ', ' not ');
146149

147150
// Escape
148151
keyword = encodeURIComponent(keyword);

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"compilerOptions": {
33
"target": "ES6",
4+
"lib": ["ES6", "ES2021.String", "DOM"],
45
"module": "CommonJS",
56
"outDir": "./dist",
67
"declaration": true,

0 commit comments

Comments
 (0)