Skip to content

Commit e5aa58b

Browse files
committed
Restructure & Introduce Address Formatting
1 parent fdfe71e commit e5aa58b

File tree

22 files changed

+648
-654
lines changed

22 files changed

+648
-654
lines changed

pnpm-lock.yaml

Lines changed: 604 additions & 632 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/format/address/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export const AddressRegex = /^0x[\dA-Fa-f]{40}$/;
2+
3+
/**
4+
* Formats the address from 0x225f137127d9067788314bc7fcc1f36746a3c3B5 to 0x225f...c3B5
5+
* Returns the address if it doesn't match the address pattern
6+
* @param address The address to format
7+
*/
8+
export const formatAddress = (address: string) => {
9+
if (address.match(AddressRegex) === null) return address;
10+
11+
return `${address.slice(0, 5)}...${address.slice(-4)}`;
12+
};

src/format/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export * from './address';
12
export { formatRecord } from './records';
23
export { formatDiscordRules } from './records/discord/discord';
34
export { formatLinkedinRules } from './records/linkedin/linkedin';

src/format/records/discord/discord.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { formatter } from '../../formatter';
1+
import { formatter } from '../formatter';
22

33
export const formatDiscordRules = formatter([
44
(record) =>
File renamed without changes.

src/format/records/github/github.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { formatter } from '../../formatter';
1+
import { formatter } from '../formatter';
22

33
export const formatGithubRules = formatter([
44
(record) => record.replace(/^(https?:\/\/)?(www\.)?github\.com\//, ''),

src/format/records.ts renamed to src/format/records/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { formatDiscordRules } from './records/discord/discord';
2-
import { formatGithubRules } from './records/github/github';
3-
import { formatLinkedinRules } from './records/linkedin/linkedin';
4-
import { formatRedditRules } from './records/reddit/reddit';
5-
import { formatTelegramRules } from './records/telegram/telegram';
6-
import { formatTwitterRules } from './records/twitter/twitter';
7-
import { formatWebsiteRules } from './records/website/website';
1+
import { formatDiscordRules } from './discord/discord';
2+
import { formatGithubRules } from './github/github';
3+
import { formatLinkedinRules } from './linkedin/linkedin';
4+
import { formatRedditRules } from './reddit/reddit';
85
import { Rule } from './rule';
6+
import { formatTelegramRules } from './telegram/telegram';
7+
import { formatTwitterRules } from './twitter/twitter';
8+
import { formatWebsiteRules } from './website/website';
99

1010
type Types =
1111
| 'com.twitter'

src/format/records/linkedin/linkedin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { formatter } from '../../formatter';
1+
import { formatter } from '../formatter';
22

33
export const formatLinkedinRules = formatter([
44
(record) =>

src/format/records/reddit/reddit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { formatter } from '../../formatter';
1+
import { formatter } from '../formatter';
22

33
export const formatRedditRules = formatter([
44
(record) => record.replace(/^(https?:\/\/)?(www\.)?reddit\.com\//, ''),
File renamed without changes.

0 commit comments

Comments
 (0)