Start fresh when updating embeds for links
In a previous commit I was attempting to be clever by only replacing/removing embeds if necessary. This not only made the logic more confusing but introduced a bug that would allow for orphaned embeds when updating the search params of a URL. This commit will remove all embeds that have a `.url` property and start fresh. This simplifies the code and eliminates the aforementioned bug.
This commit is contained in:
parent
f9cfb46e73
commit
184433b078
@ -290,18 +290,13 @@ export async function postHandleMessage(message: Message) {
|
||||
}
|
||||
}
|
||||
|
||||
// Remove existing embeds whose URLs ARE in the current message (we'll regenerate them)
|
||||
// Remove ALL embeds that have URLs when processing links (start fresh)
|
||||
data.embeds = data.embeds.filter((embed) => {
|
||||
if (!embed.url) {
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
const normalizedEmbedUrl = normalizeUrl(embed.url);
|
||||
const shouldRemove = currentNormalizedUrls.has(normalizedEmbedUrl);
|
||||
return !shouldRemove;
|
||||
} catch {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
const seenNormalizedUrls = new Set<string>();
|
||||
|
||||
Reference in New Issue
Block a user