diff --git a/ROADMAP.md b/ROADMAP.md index 916b87ff..42565e68 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1,6 +1,5 @@ # Current -- [ ] Check mention interpolation indexes nevent1qqsx27cspgfcj93kryt2zpzzt5ua60rtucckvcmsrqc949e6t83jaxspzemhxue69uhhyetvv9ujumn0wd68ytnzv9hxg46e8sv - [ ] Show loading/success on zap invoice screen - [ ] Fix iOS/safari/firefox - [ ] Update https://nostr.com/clients/coracle diff --git a/src/util/html.ts b/src/util/html.ts index 3bf56930..2ab1f2c6 100644 --- a/src/util/html.ts +++ b/src/util/html.ts @@ -1,3 +1,4 @@ +import {uniq} from 'ramda' import {ellipsize, bytes} from 'hurdak/lib/hurdak' export const copyToClipboard = text => { @@ -123,9 +124,7 @@ export const renderContent = content => { content = escapeHtml(content) // Extract urls - for (let url of extractUrls(content)) { - const $a = document.createElement('a') - + for (let url of uniq(extractUrls(content))) { // It's common for a period to end a url, trim it off if (url.endsWith('.')) { url = url.slice(0, -1) @@ -133,13 +132,16 @@ export const renderContent = content => { const href = url.includes('://') ? url : 'https://' + url const display = url.replace(/https?:\/\/(www\.)?/, '') + const regex = new RegExp(url, 'g') + + const $a = document.createElement('a') $a.href = href $a.target = "_blank" $a.className = "underline" $a.innerText = ellipsize(display, 50) - content = content.replace(url, $a.outerHTML) + content = content.replace(regex, $a.outerHTML) } return content.trim()