diff options
Diffstat (limited to 'packages/react-shared/src/utils/utils.ts')
-rw-r--r-- | packages/react-shared/src/utils/utils.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/packages/react-shared/src/utils/utils.ts b/packages/react-shared/src/utils/utils.ts index 93c7e9f7b..0c0e7722c 100644 --- a/packages/react-shared/src/utils/utils.ts +++ b/packages/react-shared/src/utils/utils.ts @@ -33,6 +33,27 @@ export const utils = { convertDashesToSpaces(text: string): string { 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; + }, getEtherScanLinkIfExists( addressOrTxHash: string, networkId: number, |