(value: string)
| 121 | } |
| 122 | |
| 123 | export function parseAllUrl(value: string): ISegment[] { |
| 124 | const valueArray: ISegment[] = []; |
| 125 | let lastEndIndex = 0; |
| 126 | |
| 127 | const regExp = new RegExp(LINK_REG); |
| 128 | let execResult = regExp.exec(value); |
| 129 | |
| 130 | if (execResult == null) { |
| 131 | return [{ |
| 132 | type: SegmentType.Text, |
| 133 | text: value, |
| 134 | }]; |
| 135 | } |
| 136 | |
| 137 | while (execResult) { |
| 138 | const startIndex = execResult.index; |
| 139 | const regExpMatch = execResult[0]!; |
| 140 | |
| 141 | if (startIndex !== lastEndIndex) { |
| 142 | valueArray.push({ |
| 143 | type: SegmentType.Text, |
| 144 | text: value.substring(lastEndIndex, startIndex), |
| 145 | }); |
| 146 | } |
| 147 | |
| 148 | if (hasUrlProtocol(regExpMatch)) { |
| 149 | valueArray.push({ type: SegmentType.Url, link: regExpMatch, text: regExpMatch }); |
| 150 | } else if (isUrl(regExpMatch)) { |
| 151 | valueArray.push({ type: SegmentType.Url, link: `http://${regExpMatch}`, text: regExpMatch }); |
| 152 | } else if (isEmailUrl(regExpMatch)) { |
| 153 | valueArray.push({ type: SegmentType.Url, link: `mailto:${regExpMatch}`, text: regExpMatch }); |
| 154 | } |
| 155 | |
| 156 | lastEndIndex = regExp.lastIndex; |
| 157 | execResult = regExp.exec(value); |
| 158 | } |
| 159 | |
| 160 | if (lastEndIndex < value.length) { |
| 161 | valueArray.push({ |
| 162 | type: SegmentType.Text, |
| 163 | text: value.substring(lastEndIndex), |
| 164 | }); |
| 165 | } |
| 166 | |
| 167 | return valueArray; |
| 168 | } |
| 169 | |
| 170 | export const stringHash2Number = (str: string, range: number): number => { |
| 171 | /** |
nothing calls this directly
no test coverage detected