Commit 5a3aaeb0 authored by JC Brand's avatar JC Brand

Prevent default when opening chat via xmpp: URI

parent 01ee9429
......@@ -841,7 +841,7 @@ describe("Groupchats", function () {
await u.waitUntil(() => view.el.querySelector('.chat-msg__text a'));
view.el.querySelector('.chat-msg__text a').click();
await u.waitUntil(() => _converse.chatboxes.length === 3)
expect(_.includes(_converse.chatboxes.pluck('id'), 'coven@chat.shakespeare.lit')).toBe(true);
expect(_converse.chatboxes.pluck('id').includes('coven@chat.shakespeare.lit')).toBe(true);
done()
}));
......
......@@ -323,6 +323,12 @@ u.convertToImageTag = function (url, onLoad, onClick) {
return tpl_image({url, onClick, onLoad});
};
function onClickXMPPURI (ev) {
ev.preventDefault();
api.rooms.open(ev.target.href);
}
u.convertURIoHyperlink = function (uri, urlAsTyped) {
let normalized_url = uri.normalize()._string;
const pretty_url = uri._parts.urn ? normalized_url : uri.readable();
......@@ -334,7 +340,7 @@ u.convertURIoHyperlink = function (uri, urlAsTyped) {
return html`
<a target="_blank"
rel="noopener"
@click=${ev => api.rooms.open(ev.target.href)}
@click=${onClickXMPPURI}
href="${normalized_url}">${visible_url}</a>`;
}
return html`<a target="_blank" rel="noopener" href="${normalized_url}">${visible_url}</a>`;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment