aboutsummaryrefslogtreecommitdiffstats
path: root/packages/react-shared
diff options
context:
space:
mode:
Diffstat (limited to 'packages/react-shared')
-rw-r--r--packages/react-shared/package.json1
-rw-r--r--packages/react-shared/src/utils/utils.ts21
2 files changed, 3 insertions, 19 deletions
diff --git a/packages/react-shared/package.json b/packages/react-shared/package.json
index 5df4648ee..d73d6c162 100644
--- a/packages/react-shared/package.json
+++ b/packages/react-shared/package.json
@@ -41,6 +41,7 @@
"@types/react-dom": "*",
"@types/react-scroll": "1.5.3",
"basscss": "^8.0.3",
+ "change-case": "^3.0.2",
"is-mobile": "^0.2.2",
"lodash": "^4.17.5",
"material-ui": "^0.17.1",
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,