diff --git a/src/Util.js b/src/Util.js index 40390fcb..634a7181 100644 --- a/src/Util.js +++ b/src/Util.js @@ -78,7 +78,7 @@ export const Reaction = { * @returns */ export function normalizeReaction(content) { - switch(content) { + switch (content) { case "": return Reaction.Positive; case "🤙": return Reaction.Positive; case "❤️": return Reaction.Positive; @@ -89,4 +89,26 @@ export function normalizeReaction(content) { case "👎": return Reaction.Negative; } return content; +} + +/** + * Converts LNURL service to LN Address + * @param {string} lnurl + * @returns + */ +export function extractLnAddress(lnurl) { + // some clients incorrectly set this to LNURL service, patch this + if (lnurl.toLowerCase().startsWith("lnurl")) { + let url = bech32ToText(lnurl); + if (url.startsWith("http")) { + let parsedUri = new URL(url); + // is lightning address + if (parsedUri.pathname.startsWith("/.well-known/lnurlp/")) { + let pathParts = parsedUri.pathname.split('/'); + let username = pathParts[pathParts.length - 1]; + return `${username}@${parsedUri.hostname}`; + } + } + } + return lnurl; } \ No newline at end of file diff --git a/src/element/Copy.css b/src/element/Copy.css new file mode 100644 index 00000000..3a949667 --- /dev/null +++ b/src/element/Copy.css @@ -0,0 +1,14 @@ +.copy { + user-select: none; + cursor: pointer; +} + +.copy .body { + font-family: monospace; + font-size: 14px; + margin: 0; + width: 18em; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} \ No newline at end of file diff --git a/src/element/Copy.js b/src/element/Copy.js new file mode 100644 index 00000000..f70d8803 --- /dev/null +++ b/src/element/Copy.js @@ -0,0 +1,21 @@ +import "./Copy.css"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { faCopy, faCheck } from "@fortawesome/free-solid-svg-icons"; +import { useCopy } from "../useCopy"; + +export default function Copy(props) { + + const { copy, copied, error } = useCopy(); + return ( +
+ {props.text} +
+- {params.id} -
-{extractLinks([about])}
- {website ? {website} : null} +{extractLinks([user?.about])}
+ {user?.website ? {user?.website} : null} {lnurl ?