From ebf862aac9d3083640dcef182ea403d1691d9be0 Mon Sep 17 00:00:00 2001 From: tiendn Date: Thu, 2 May 2024 21:50:02 +0700 Subject: [PATCH 1/4] fix: issue 1381 using startWiths instead of substring for check string prefixess --- web-ui/utils/string.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web-ui/utils/string.ts b/web-ui/utils/string.ts index 9bf597cbe..a8f8cf221 100644 --- a/web-ui/utils/string.ts +++ b/web-ui/utils/string.ts @@ -1,5 +1,5 @@ export function formatQasset(denom: string): string { - if (denom.substring(0, 1) == "Q" || denom.substring(0, 2) == "AQ"){ + if (denom.startsWith("Q") || denom.startsWith("AQ")){ return "q"+denom.substring(1) } return denom From 659a160f73e4e3575c47d2473ada534ac66c56a2 Mon Sep 17 00:00:00 2001 From: tiendn Date: Thu, 2 May 2024 21:58:40 +0700 Subject: [PATCH 2/4] style: update space for enhance the readability and maintainability of the code --- web-ui/utils/string.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web-ui/utils/string.ts b/web-ui/utils/string.ts index a8f8cf221..2c47d8604 100644 --- a/web-ui/utils/string.ts +++ b/web-ui/utils/string.ts @@ -1,6 +1,6 @@ export function formatQasset(denom: string): string { if (denom.startsWith("Q") || denom.startsWith("AQ")){ - return "q"+denom.substring(1) + return "q" + denom.substring(1) } return denom } \ No newline at end of file From c5366943cb74733c7b99b12a2fc916c26ee4a3ec Mon Sep 17 00:00:00 2001 From: Tuan Tran Date: Thu, 2 May 2024 23:29:39 +0700 Subject: [PATCH 3/4] Update web-ui/utils/string.ts linting Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- web-ui/utils/string.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web-ui/utils/string.ts b/web-ui/utils/string.ts index 2c47d8604..96dbd1971 100644 --- a/web-ui/utils/string.ts +++ b/web-ui/utils/string.ts @@ -1,5 +1,8 @@ export function formatQasset(denom: string): string { - if (denom.startsWith("Q") || denom.startsWith("AQ")){ + if (denom.startsWith("Q") || denom.startsWith("AQ")) { + return "q" + denom.substring(1); + } + return denom; return "q" + denom.substring(1) } return denom From 9c797cc019c2d7401376a3c23f9e4c6de0a9fdac Mon Sep 17 00:00:00 2001 From: tiendn Date: Wed, 15 May 2024 09:12:38 +0700 Subject: [PATCH 4/4] fix: remove dup code --- web-ui/utils/string.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/web-ui/utils/string.ts b/web-ui/utils/string.ts index 96dbd1971..8e6b9e8dd 100644 --- a/web-ui/utils/string.ts +++ b/web-ui/utils/string.ts @@ -1,9 +1,7 @@ export function formatQasset(denom: string): string { - if (denom.startsWith("Q") || denom.startsWith("AQ")) { - return "q" + denom.substring(1); - } + if (denom.startsWith('Q') || denom.startsWith('AQ')) { + return 'q' + denom.substring(1); + } + return denom; - return "q" + denom.substring(1) - } - return denom } \ No newline at end of file