Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 90b572f

Browse files
authored
Inhibit url previews on MXIDs containing slashes same as those without (#11160)
1 parent cfc13c5 commit 90b572f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/components/views/messages/TextualBody.tsx

+8-8
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,14 @@ export default class TextualBody extends React.Component<IBodyProps, IState> {
388388
return false;
389389
}
390390

391+
const url = node.getAttribute("href");
392+
const host = url?.match(/^https?:\/\/(.*?)(\/|$)/)?.[1];
393+
394+
// never preview permalinks (if anything we should give a smart
395+
// preview of the room/user they point to: nobody needs to be reminded
396+
// what the matrix.to site looks like).
397+
if (!host || isPermalinkHost(host)) return false;
398+
391399
// as a random heuristic to avoid highlighting things like "foo.pl"
392400
// we require the linked text to either include a / (either from http://
393401
// or from a full foo.bar/baz style schemeless URL) - or be a markdown-style
@@ -397,14 +405,6 @@ export default class TextualBody extends React.Component<IBodyProps, IState> {
397405
return true;
398406
}
399407

400-
const url = node.getAttribute("href");
401-
const host = url?.match(/^https?:\/\/(.*?)(\/|$)/)?.[1];
402-
403-
// never preview permalinks (if anything we should give a smart
404-
// preview of the room/user they point to: nobody needs to be reminded
405-
// what the matrix.to site looks like).
406-
if (!host || isPermalinkHost(host)) return false;
407-
408408
if (node.textContent?.toLowerCase().trim().startsWith(host.toLowerCase())) {
409409
// it's a "foo.pl" style link
410410
return false;

0 commit comments

Comments
 (0)