Improve URL decoding and bump version for publication
This commit is contained in:
@@ -17,12 +17,15 @@ const DeepLink = ()=>{
|
||||
initTranslation();
|
||||
|
||||
const SCHEME = 'bigbluebutton-tablet://';
|
||||
const SCHEME_DEFAULT = 'https://'
|
||||
var lastDeepLinkPortalName = null;
|
||||
var lastDeepLinkPortalName:String|undefined = undefined;
|
||||
|
||||
const navigation = useNavigation();
|
||||
const {portals, setPortals} = usePortal();
|
||||
|
||||
function decodeUrlParameter(str:string) {
|
||||
return decodeURIComponent(str.replace(/\+/g, '%20'));
|
||||
}
|
||||
|
||||
async function createPortalFromDeepLink(link: string){
|
||||
const linkWithoutScheme = link.replace(SCHEME, '').replace(/\+/g, ' ');
|
||||
|
||||
@@ -30,33 +33,30 @@ const DeepLink = ()=>{
|
||||
navigation.navigate(i18next.t('mobileApp.portals.drawerNavigation.button.label'))
|
||||
return Alert.alert(i18next.t('mobileApp.portals.handleWithoutURL'))
|
||||
}
|
||||
let roomNameWBar = linkWithoutScheme.match(/^[-.\w +]+\//)
|
||||
if(!roomNameWBar) {
|
||||
|
||||
const linkParts = linkWithoutScheme.split('/https://');
|
||||
let portalName = linkParts[0];
|
||||
let portalLink = linkParts[1];
|
||||
|
||||
if(!portalName || !portalLink) {
|
||||
navigation.navigate(i18next.t('mobileApp.portals.drawerNavigation.button.label'))
|
||||
return Alert.alert(i18next.t('mobileApp.portals.handleWithoutURL'))
|
||||
}
|
||||
let roomName = roomNameWBar[0].replace(/\//, '')
|
||||
|
||||
if(roomName === 'bigbluebutton'){
|
||||
roomName = i18next.t('mobileApp.portals.namePortal.deepLink');
|
||||
}
|
||||
lastDeepLinkPortalName = roomName;
|
||||
|
||||
let linkWithoutSchemeAndName = linkWithoutScheme.replace(/^[-.\w +]+\//, '')
|
||||
|
||||
if (!linkWithoutSchemeAndName.includes('://')) {
|
||||
linkWithoutSchemeAndName = SCHEME_DEFAULT + linkWithoutSchemeAndName
|
||||
}
|
||||
portalName=decodeUrlParameter(portalName);
|
||||
portalLink= 'https://' + decodeUrlParameter(portalLink);
|
||||
|
||||
// Join links are temporary (discarded on next app launch)
|
||||
const isTemporary = linkWithoutScheme.includes('/bigbluebutton/api/join?');
|
||||
const isTemporary = portalLink.includes('/bigbluebutton/api/join?');
|
||||
|
||||
const portalToAdd:IPortal = {
|
||||
name: lastDeepLinkPortalName,
|
||||
url: linkWithoutSchemeAndName,
|
||||
name: portalName,
|
||||
url: portalLink,
|
||||
temporary: isTemporary
|
||||
}
|
||||
|
||||
lastDeepLinkPortalName = portalName;
|
||||
|
||||
// Adding LinkedPortal to AsyncStorage
|
||||
const newPortals = await createNewPortal(portalToAdd)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user