Sending channel and link together generates duplicate text
This commit is contained in:
parent
d9efaef369
commit
0e52b133af
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
const Handlebars = require("handlebars/runtime");
|
const Handlebars = require("handlebars/runtime");
|
||||||
const parseStyle = require("./ircmessageparser/parseStyle");
|
const parseStyle = require("./ircmessageparser/parseStyle");
|
||||||
|
const anyIntersection = require("./ircmessageparser/anyIntersection");
|
||||||
const findChannels = require("./ircmessageparser/findChannels");
|
const findChannels = require("./ircmessageparser/findChannels");
|
||||||
const findLinks = require("./ircmessageparser/findLinks");
|
const findLinks = require("./ircmessageparser/findLinks");
|
||||||
const findEmoji = require("./ircmessageparser/findEmoji");
|
const findEmoji = require("./ircmessageparser/findEmoji");
|
||||||
@ -66,7 +67,15 @@ module.exports = function parse(text) {
|
|||||||
const parts = channelParts
|
const parts = channelParts
|
||||||
.concat(linkParts)
|
.concat(linkParts)
|
||||||
.concat(emojiParts)
|
.concat(emojiParts)
|
||||||
.sort((a, b) => a.start - b.start);
|
.sort((a, b) => a.start - b.start || b.end - a.end)
|
||||||
|
.reduce((prev, curr) => {
|
||||||
|
const intersection = prev.some((p) => anyIntersection(p, curr));
|
||||||
|
|
||||||
|
if (intersection) {
|
||||||
|
return prev;
|
||||||
|
}
|
||||||
|
return prev.concat([curr]);
|
||||||
|
}, []);
|
||||||
|
|
||||||
// Merge the styling information with the channels / URLs / text objects and
|
// Merge the styling information with the channels / URLs / text objects and
|
||||||
// generate HTML strings with the resulting fragments
|
// generate HTML strings with the resulting fragments
|
||||||
|
Loading…
Reference in New Issue
Block a user