From f36c9565362b741c58672204fe0c155252affe28 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Tue, 24 Jan 2023 13:00:11 -0600 Subject: Resolve all remaining lint issues (#88) * Rework 'navIdx' variables from number arrays to strings to avoid equality-check failures in react hooks * Resolve all remaining lint issues * Fix tests * Use node v18 in gh action test --- src/lib/strings.ts | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'src/lib/strings.ts') diff --git a/src/lib/strings.ts b/src/lib/strings.ts index 24b8bcafa..cb79e8824 100644 --- a/src/lib/strings.ts +++ b/src/lib/strings.ts @@ -78,7 +78,7 @@ export function extractEntities( let ents: Entity[] = [] { // mentions - const re = /(^|\s|\()(@)([a-zA-Z0-9\.-]+)(\b)/g + const re = /(^|\s|\()(@)([a-zA-Z0-9.-]+)(\b)/g while ((match = re.exec(text))) { if (knownHandles && !knownHandles.has(match[3])) { continue // not a known handle @@ -133,7 +133,7 @@ interface DetectedLink { type DetectedLinkable = string | DetectedLink export function detectLinkables(text: string): DetectedLinkable[] { const re = - /((^|\s|\()@[a-z0-9\.-]*)|((^|\s|\()https?:\/\/[\S]+)|((^|\s|\()(?[a-z][a-z0-9]*(\.[a-z0-9]+)+)[\S]*)/gi + /((^|\s|\()@[a-z0-9.-]*)|((^|\s|\()https?:\/\/[\S]+)|((^|\s|\()(?[a-z][a-z0-9]*(\.[a-z0-9]+)+)[\S]*)/gi const segments = [] let match let start = 0 @@ -154,14 +154,12 @@ export function detectLinkables(text: string): DetectedLinkable[] { matchValue = matchValue.slice(1) } - { - // strip ending puncuation - if (/[.,;!?]$/.test(matchValue)) { - matchValue = matchValue.slice(0, -1) - } - if (/[)]$/.test(matchValue) && !matchValue.includes('(')) { - matchValue = matchValue.slice(0, -1) - } + // strip ending puncuation + if (/[.,;!?]$/.test(matchValue)) { + matchValue = matchValue.slice(0, -1) + } + if (/[)]$/.test(matchValue) && !matchValue.includes('(')) { + matchValue = matchValue.slice(0, -1) } if (start !== matchIndex) { @@ -185,8 +183,8 @@ export function makeValidHandle(str: string): string { } export function createFullHandle(name: string, domain: string): string { - name = (name || '').replace(/[\.]+$/, '') - domain = (domain || '').replace(/^[\.]+/, '') + name = (name || '').replace(/[.]+$/, '') + domain = (domain || '').replace(/^[.]+/, '') return `${name}.${domain}` } -- cgit 1.4.1