Skip to content

Commit 8a39923

Browse files
committed
fix: better code
1 parent bc654d6 commit 8a39923

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/utils/logs.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,9 @@ export function getLogsLink({dbName, logging}: GetLogsLinkProps): string {
2121
if (queryParam) {
2222
const decodedQuery = decodeURIComponent(queryParam);
2323

24-
// Gets content between curly braces and replaces with {content, database = "dbName"}
25-
const updatedQuery = decodedQuery.replace(/\{([^}]*)\}/, (_match, contents) => {
26-
const trimmedContents = contents.trim();
27-
if (trimmedContents) {
28-
return `{${trimmedContents}, database = "${dbName}"}`;
29-
} else {
30-
return `{database = "${dbName}"}`;
31-
}
32-
});
24+
const queryBetweenBraces = decodedQuery.slice(1, -1);
25+
const witComma = queryBetweenBraces.length > 0;
26+
const updatedQuery = `{${queryBetweenBraces}${witComma ? ', ' : ''}database = "${dbName}"}`;
3327

3428
url.searchParams.set('query', updatedQuery);
3529
}

0 commit comments

Comments
 (0)