diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-01-24 13:00:11 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-24 13:00:11 -0600 |
commit | f36c9565362b741c58672204fe0c155252affe28 (patch) | |
tree | 85d90f3caae2c8f2103ec50346f9274cf8b243c5 /src/lib | |
parent | 3a90114f3afc66cfef70c71c2ee343c29e1f3e8d (diff) | |
download | voidsky-f36c9565362b741c58672204fe0c155252affe28.tar.zst |
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
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/strings.ts | 22 |
1 files changed, 10 insertions, 12 deletions
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|\()(?<domain>[a-z][a-z0-9]*(\.[a-z0-9]+)+)[\S]*)/gi + /((^|\s|\()@[a-z0-9.-]*)|((^|\s|\()https?:\/\/[\S]+)|((^|\s|\()(?<domain>[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}` } |