aboutsummaryrefslogtreecommitdiffstats
path: root/packages/react-shared/src/utils/utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/react-shared/src/utils/utils.ts')
-rw-r--r--packages/react-shared/src/utils/utils.ts21
1 files changed, 2 insertions, 19 deletions
diff --git a/packages/react-shared/src/utils/utils.ts b/packages/react-shared/src/utils/utils.ts
index d6b2a5cf5..15c55c04b 100644
--- a/packages/react-shared/src/utils/utils.ts
+++ b/packages/react-shared/src/utils/utils.ts
@@ -1,3 +1,4 @@
+import changeCase = require('change-case');
import isMobile = require('is-mobile');
import * as _ from 'lodash';
import { scroller } from 'react-scroll';
@@ -34,25 +35,7 @@ export const utils = {
return text.replace(/-/g, ' ');
},
convertCamelCaseToSpaces(text: string): string {
- const charArray = _.map(text, (char, i) => {
- const isNumber = !_.eq(_.parseInt(char), NaN);
- const isPrevNumber = i !== 0 && !_.eq(_.parseInt(text[i - 1]), NaN);
- if (isNumber && (i === 0 || isPrevNumber)) {
- return char;
- }
- if (char === char.toUpperCase() && i !== 0) {
- return ` ${char}`;
- }
- return char;
- });
- let finalText = charArray.join('');
- const exceptions = { 'EIP ': 'E I P', 'ZRX ': 'Z R X', 'ERC ': 'E R C', RPC: 'R P C' };
- _.each(exceptions, (spaced, normal) => {
- if (_.includes(finalText, spaced)) {
- finalText = finalText.replace(spaced, normal);
- }
- });
- return finalText;
+ return changeCase.snake(text).replace(/_/g, ' ');
},
getEtherScanLinkIfExists(
addressOrTxHash: string,