Revert "ignore hash/fragment when de-duplicating links for url previews"

pull/21833/head
Michael Telatynski 2021-07-07 14:30:08 +01:00 committed by GitHub
parent b916b789aa
commit 30fa5419db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 8 deletions

View File

@ -294,15 +294,15 @@ export default class TextualBody extends React.Component<IProps, IState> {
// pass only the first child which is the event tile otherwise this recurses on edited events
let links = this.findLinks([this.contentRef.current]);
if (links.length) {
// de-duplicate the links after stripping hashes as they don't affect the preview
// using a set here maintains the order
links = Array.from(new Set(links.map(link => {
const url = new URL(link);
url.hash = "";
return url.toString();
})));
// de-dup the links (but preserve ordering)
const seen = new Set();
links = links.filter((link) => {
if (seen.has(link)) return false;
seen.add(link);
return true;
});
this.setState({ links });
this.setState({ links: links });
// lazy-load the hidden state of the preview widget from localstorage
if (window.localStorage) {