forked from nostr/nostrweb
links: remove trailing slash in link text
due to URL formatting, the link text of https://example.com was showing as example.com/ removed trailing slash if possible.
parent
7539d11a56
commit
889a49e0ef
|
@ -117,11 +117,12 @@ export const parseTextContent = (
|
||||||
return word;
|
return word;
|
||||||
}
|
}
|
||||||
firstLink = firstLink || url.href;
|
firstLink = firstLink || url.href;
|
||||||
|
const prettierWithoutSlash = url.pathname === '/';
|
||||||
return elem('a', {
|
return elem('a', {
|
||||||
href: url.href,
|
href: url.href,
|
||||||
target: '_blank',
|
target: '_blank',
|
||||||
rel: 'noopener noreferrer'
|
rel: 'noopener noreferrer'
|
||||||
}, url.href.slice(url.protocol.length + 2));
|
}, url.href.slice(url.protocol.length + 2, prettierWithoutSlash ? -1 : undefined));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return word;
|
return word;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue