Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issue 1381 using startWiths instead of substring for check stringg prefixess #1557

Closed
9 changes: 5 additions & 4 deletions web-ui/utils/string.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export function formatQasset(denom: string): string {
if (denom.substring(0, 1) == "Q" || denom.substring(0, 2) == "AQ"){
return "q"+denom.substring(1)
}
return denom
if (denom.startsWith('Q') || denom.startsWith('AQ')) {
return 'q' + denom.substring(1);
}
Comment on lines +2 to +4
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure consistent return format for formatQasset.

The function formatQasset is documented to return a string, but the format of the returned string varies depending on the condition. If denom starts with "Q" or "AQ", it returns "q" + denom.substring(1), which alters the string. Otherwise, it returns denom unchanged. Consider normalizing the return format or clarifying the function's purpose and expected behavior in the documentation.


Improve code formatting for better readability.

- if (denom.startsWith('Q') || denom.startsWith('AQ')) {
-     return 'q' + denom.substring(1);
- }
+ if (denom.startsWith('Q') || denom.startsWith('AQ')) {
+     return 'q' + denom.substring(1);
+ }

Adding spaces around operators and after conditions, as well as semicolons at the end of statements, will enhance the readability and maintainability of the code.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
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;
}
Loading