Browse Source

Support new /joinchat/ url format

master
morethanwords 3 years ago
parent
commit
1d388fe62a
  1. 3
      src/lib/appManagers/appImManager.ts
  2. 6
      src/lib/richtextprocessor.ts

3
src/lib/appManagers/appImManager.ts

@ -308,12 +308,13 @@ export class AppImManager {
} }
}); });
// Support old t.me/joinchat/asd and new t.me/+asd
this.addAnchorListener<{pathnameParams: ['joinchat', string]}>({ this.addAnchorListener<{pathnameParams: ['joinchat', string]}>({
name: 'joinchat', name: 'joinchat',
callback: ({pathnameParams}) => { callback: ({pathnameParams}) => {
const link: InternalLink = { const link: InternalLink = {
_: INTERNAL_LINK_TYPE.JOIN_CHAT, _: INTERNAL_LINK_TYPE.JOIN_CHAT,
invite: pathnameParams[1] invite: pathnameParams[1] || decodeURIComponent(pathnameParams[0]).slice(1)
}; };
this.processInternalLink(link); this.processInternalLink(link);

6
src/lib/richtextprocessor.ts

@ -847,6 +847,12 @@ namespace RichTextProcessor {
url = 'tg://unsafe_url?url=' + encodeURIComponent(url); url = 'tg://unsafe_url?url=' + encodeURIComponent(url);
} else */if((tgMeMatch = url.match(/^(?:https?:\/\/)?t(?:elegram)?\.me\/(.+)/))) { } else */if((tgMeMatch = url.match(/^(?:https?:\/\/)?t(?:elegram)?\.me\/(.+)/))) {
const fullPath = tgMeMatch[1]; const fullPath = tgMeMatch[1];
if(/^\W/.test(fullPath)) {
onclick = 'joinchat';
return {url, onclick};
}
const path = fullPath.split('/'); const path = fullPath.split('/');
switch(path[0]) { switch(path[0]) {
case 'joinchat': case 'joinchat':

Loading…
Cancel
Save