mirror of
https://github.com/irislib/iris-messenger.git
synced 2024-09-19 17:46:33 +00:00
hide img urls from line beginning & end
This commit is contained in:
parent
fc3333a2d4
commit
cb4bc4412e
@ -74,7 +74,7 @@
|
||||
"history": "5.3.0",
|
||||
"htm": "^3.1.1",
|
||||
"identicon.js": "^2.3.3",
|
||||
"iris-lib": "^0.1.16",
|
||||
"iris-lib": "^0.1.17",
|
||||
"jquery": "^3.6.1",
|
||||
"jsxstyle": "^2.5.1",
|
||||
"localforage": "^1.10.0",
|
||||
|
@ -138,10 +138,10 @@ class PublicMessage extends Message {
|
||||
if (this.props.standalone && msg.attachments && msg.attachments.length) {
|
||||
this.setOgImageUrl(msg.attachments[0].data);
|
||||
}
|
||||
this.setState({ msg });
|
||||
|
||||
// find .jpg .jpeg .gif .png urls in msg.text and add them to msg.attachments
|
||||
if (msg.text) {
|
||||
let text = msg.text;
|
||||
const urls = msg.text.match(/(https?:\/\/[^\s]+)/g);
|
||||
if (urls) {
|
||||
urls.forEach((url) => {
|
||||
@ -151,11 +151,19 @@ class PublicMessage extends Message {
|
||||
msg.attachments = [];
|
||||
}
|
||||
msg.attachments.push({ type: 'image', data: parsedUrl.origin + parsedUrl.pathname });
|
||||
|
||||
// Remove URL from beginning or end of line
|
||||
text = text
|
||||
.replace(new RegExp(`^${url}`, 'g'), '')
|
||||
.replace(new RegExp(`${url}$`, 'g'), '');
|
||||
}
|
||||
});
|
||||
}
|
||||
msg.text = text;
|
||||
}
|
||||
|
||||
this.setState({ msg });
|
||||
|
||||
if (nostrId) {
|
||||
Nostr.getRepliesAndLikes(nostrId, (replies, likes, threadReplyCount) => {
|
||||
this.likedBy = new Set(likes);
|
||||
|
@ -7863,10 +7863,10 @@ ipaddr.js@1.9.1:
|
||||
resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-2.0.1.tgz#eca256a7a877e917aeb368b0a7497ddf42ef81c0"
|
||||
integrity sha512-1qTgH9NG+IIJ4yfKs2e6Pp1bZg8wbDbKHT21HrLIeYBTRLgMYKnMTPAuI3Lcs61nfx5h1xlXnbJtH1kX5/d/ng==
|
||||
|
||||
iris-lib@^0.1.16:
|
||||
version "0.1.16"
|
||||
resolved "https://registry.yarnpkg.com/iris-lib/-/iris-lib-0.1.16.tgz#6bfba5452b1e5f6799e0f9222ab3c07c3c21182e"
|
||||
integrity sha512-eEBwlV0CXcJoPOvbkC71oz+CVTBoLbjWU9YcD+MS2LwhP7zVaZVXojoT8ruQqaJW6tRpwL1YP4g7vmr7LCKa3Q==
|
||||
iris-lib@^0.1.17:
|
||||
version "0.1.17"
|
||||
resolved "https://registry.yarnpkg.com/iris-lib/-/iris-lib-0.1.17.tgz#1d46405c04a47efd8c82226a6aab31642d4b250b"
|
||||
integrity sha512-bMJ6EJ1J1WzWSYEEf7LS66aMg+ljef0/NKhCd06pyrSkQ068LLuTuy4qW+JyB7spNgBA7Kanmyy92irsOzkuEA==
|
||||
dependencies:
|
||||
"@noble/secp256k1" "^1.7.0"
|
||||
elliptic "^6.5.4"
|
||||
|
Loading…
Reference in New Issue
Block a user