Skip to content

Commit

Permalink
[IMPROVE] Preview message URLs only once (#22516)
Browse files Browse the repository at this point in the history
  • Loading branch information
nmagedman authored Jul 1, 2021
1 parent aa7ee7b commit f60a471
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/lib/server/functions/insertMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const insertMessage = function(user, message, rid, upsert = false) {

const urls = message.html.match(/([A-Za-z]{3,9}):\/\/([-;:&=\+\$,\w]+@{1})?([-A-Za-z0-9\.]+)+:?(\d+)?((\/[-\+=!:~%\/\.@\,\(\)\w]*)?\??([-\+=&!:;%@\/\.\,\w]+)?(?:#([^\s\)]+))?)?/g);
if (urls) {
message.urls = urls.map((url) => ({ url }));
message.urls = [...new Set(urls)].map((url) => ({ url }));
}

message = Markdown.mountTokensBack(message, false);
Expand Down
2 changes: 1 addition & 1 deletion app/lib/server/functions/parseUrlsInMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const parseUrlsInMessage = (message) => {

const urls = message.html.match(/([A-Za-z]{3,9}):\/\/([-;:&=\+\$,\w]+@{1})?([-A-Za-z0-9\.]+)+:?(\d+)?((\/[-\+=!:~%\/\.@\,\w]*)?\??([-\+=&!:;%@\/\.\,\w]+)?(?:#([^\s\)]+))?)?/g) || [];
if (urls) {
message.urls = urls.map((url) => ({ url }));
message.urls = [...new Set(urls)].map((url) => ({ url }));
}

message = Markdown.mountTokensBack(message, false);
Expand Down

0 comments on commit f60a471

Please sign in to comment.