mirror of https://github.com/vector-im/riot-web
Revert "ignore hash/fragment when de-duplicating links for url previews"
parent
b916b789aa
commit
30fa5419db
|
@ -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
|
// pass only the first child which is the event tile otherwise this recurses on edited events
|
||||||
let links = this.findLinks([this.contentRef.current]);
|
let links = this.findLinks([this.contentRef.current]);
|
||||||
if (links.length) {
|
if (links.length) {
|
||||||
// de-duplicate the links after stripping hashes as they don't affect the preview
|
// de-dup the links (but preserve ordering)
|
||||||
// using a set here maintains the order
|
const seen = new Set();
|
||||||
links = Array.from(new Set(links.map(link => {
|
links = links.filter((link) => {
|
||||||
const url = new URL(link);
|
if (seen.has(link)) return false;
|
||||||
url.hash = "";
|
seen.add(link);
|
||||||
return url.toString();
|
return true;
|
||||||
})));
|
});
|
||||||
|
|
||||||
this.setState({ links });
|
this.setState({ links: links });
|
||||||
|
|
||||||
// lazy-load the hidden state of the preview widget from localstorage
|
// lazy-load the hidden state of the preview widget from localstorage
|
||||||
if (window.localStorage) {
|
if (window.localStorage) {
|
||||||
|
|
Loading…
Reference in New Issue