Skip to content

Commit 17adf48

Browse files
committed
Improve readability
1 parent ec5df2a commit 17adf48

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,16 @@ function convertBundleIntoReact(
106106
let index = 0;
107107
let match: RegExpExecArray | null;
108108
while ((match = linkRegex.exec(bundle.content)) !== null) {
109-
const startIndex = match.index + match[1].length;
109+
const [ , pre, url, post ] = match;
110+
111+
const startIndex = match.index + pre.length;
110112
if (startIndex > index) {
111113
content.push(bundle.content.substring(index, startIndex));
112114
}
113115

114-
const link = match[2];
115116
// Make sure the href we generate from the link is fully qualified. We assume http
116117
// if it starts with a www because many sites don't support https
117-
const href = link.startsWith("www.") ? `http://${link}` : link;
118+
const href = url.startsWith("www.") ? `http://${url}` : url;
118119
content.push(
119120
React.createElement(
120121
"a",
@@ -123,11 +124,11 @@ function convertBundleIntoReact(
123124
href,
124125
target: "_blank"
125126
},
126-
`${link}`
127+
`${url}`
127128
)
128129
);
129130

130-
const endIndex = linkRegex.lastIndex - match[3].length;
131+
const endIndex = linkRegex.lastIndex - post.length;
131132
index = endIndex;
132133
}
133134

0 commit comments

Comments
 (0)