+ {showLoading ? (
+
+
+ Searching…
+
+ ) : null}
+
+ {showError ? (
+
+ {state.error}
+
+ ) : null}
+
+ {showNoResults ? (
+
+ No links matching {trimmedQuery}
+
+ ) : null}
+
+ {showResults
+ ? results.map((link, index) => {
+ const exact = isExactMatch(link, trimmedQuery);
+ const isActive = index === activeIndex;
+ const shortLinkHref = `/links/${encodeURIComponent(link.id)}/go`;
+ const safeUrl =
+ link.linkType === 'redirect' ? safeLinkTargetUrl(link.targetUrl) : null;
+ return (
+
handleSelect(link)}
+ onMouseEnter={() => setActiveIndex(index)}
+ >
+
+ {link.linkType === 'redirect' && link.targetUrl ? (
+
+ {safeUrl ? (
+
+ {link.targetUrl}
+
+ ) : (
+ Invalid target
+ )}
+
+ ) : link.linkType === 'custom' ? (
+
+ Custom page
+
+ ) : null}
+
+
+ {link.clickCount.toLocaleString()} click{link.clickCount !== 1 ? 's' : ''}
+
+
+
+ );
+ })
+ : null}
+