Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
muc_show_logs_before_join: true,
notify_all_room_messages: ['discuss@conference.conversejs.org'],
fetch_url_headers: true,
whitelisted_plugins: ['converse-debug','converse-protocol-handler'],
whitelisted_plugins: ['converse-debug'],
bosh_service_url: 'https://conversejs.org/http-bind/', // Please use this connection manager only for testing purposes
// view_mode: 'overlayed',
show_controlbox_by_default: true,
Expand Down
11 changes: 10 additions & 1 deletion src/headless/plugins/chat/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@ export function routeToChat (event) {
return;
}
event?.preventDefault();
const jid = location.hash.split('=').pop();
let jid = location.hash.split('=').pop();
// decodeURIComponent is needed in case the JID contains special characters
// that were URL-encoded, e.g. `user%40domain` instead of `user@domain`.
jid = decodeURIComponent(jid);

// Remove xmpp: prefix if present
if (jid.startsWith('xmpp:')) {
jid = jid.slice(5);
}

if (!u.isValidJID(jid)) {
return log.warn(`Invalid JID "${jid}" provided in URL fragment`);
}
Expand Down
1 change: 0 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import "./plugins/rosterview/index.js";
import "./plugins/singleton/index.js";
import "./plugins/dragresize/index.js"; // Allows chat boxes to be resized by dragging them
import "./plugins/fullscreen/index.js";
import "./plugins/protocol-handler/index.js"; // Handle xmpp: links
/* END: Removable components */

_converse.exports.CustomElement = CustomElement;
Expand Down
8 changes: 8 additions & 0 deletions src/plugins/chatview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ converse.plugins.add('converse-chatview', {
Object.assign(_converse, exports); // DEPRECATED
Object.assign(_converse.exports, exports);

if ('registerProtocolHandler' in navigator) {
try {
const handlerUrl = `${window.location.origin}${window.location.pathname}#converse/chat?jid=%s`;
navigator.registerProtocolHandler('xmpp', handlerUrl);
} catch (error) {
console.warn('Failed to register protocol handler:', error);
}
}
api.listen.on('connected', () => api.disco.own.features.add(Strophe.NS.SPOILER));
api.listen.on('chatBoxClosed', (model) => clearHistory(model.get('jid')));
}
Expand Down
58 changes: 0 additions & 58 deletions src/plugins/protocol-handler/index.js

This file was deleted.

Loading