Skip to content

Commit c2d8537

Browse files
author
Gabriele Panico
committed
bug-fixed: cannot find route if userFullname contains /
1 parent a862e72 commit c2d8537

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/app/app.component.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -886,10 +886,15 @@ export class AppComponent implements OnInit {
886886

887887
let pageUrl = 'conversation-detail/'
888888
if (IDConv && FullNameConv) {
889-
pageUrl += IDConv + '/' + FullNameConv + '/' + Convtype
889+
pageUrl += IDConv + '/' + encodeURIComponent(FullNameConv) + '/' + Convtype
890890
}
891+
892+
const queryParams = this.route.snapshot.queryParams;
893+
const queryString = new URLSearchParams(queryParams).toString();
894+
pageUrl += queryString ? `?${queryString}` : '';
895+
891896
// replace(/\(/g, '%28').replace(/\)/g, '%29') -> used for the encoder of any round brackets
892-
this.router.navigateByUrl(pageUrl.replace(/\(/g, '%28').replace(/\)/g, '%29').replace( /#/g, "%23" ));
897+
this.router.navigateByUrl(pageUrl.replace(/\(/g, '%28').replace(/\)/g, '%29'));
893898

894899

895900
// const DASHBOARD_URL = this.appConfigProvider.getConfig().DASHBOARD_URL;
@@ -1299,7 +1304,7 @@ export class AppComponent implements OnInit {
12991304
subscribeChangedConversationSelected = (user: UserModel, type: string) => {
13001305
this.logger.log('[APP-COMP] subscribeUidConvSelectedChanged navigateByUrl', user, type);
13011306
// this.router.navigateByUrl('conversation-detail/' + user.uid + '?conversationWithFullname=' + user.fullname);
1302-
this.router.navigateByUrl('conversation-detail/' + user.uid + '/' + user.fullname + '/' + type);
1307+
this.router.navigateByUrl('conversation-detail/' + user.uid + '/' + encodeURIComponent(user.fullname) + '/' + type);
13031308
}
13041309

13051310
subscribeProfileInfoButtonLogOut = (hasClickedLogout) => {
@@ -1471,10 +1476,10 @@ export class AppComponent implements OnInit {
14711476
let Convtype = 'active'
14721477

14731478
if (IDConv && FullNameConv) {
1474-
pageUrl += IDConv + '/' + FullNameConv + '/' + Convtype
1479+
pageUrl += IDConv + '/' + encodeURIComponent(FullNameConv) + '/' + Convtype
14751480
}
14761481
// replace(/\(/g, '%28').replace(/\)/g, '%29') -> used for the encoder of any round brackets
1477-
this.router.navigateByUrl(pageUrl.replace(/\(/g, '%28').replace(/\)/g, '%29').replace( /#/g, "%23" ));
1482+
this.router.navigateByUrl(pageUrl.replace(/\(/g, '%28').replace(/\)/g, '%29'));
14781483
} else {
14791484
console.log("FCM: Received in foreground", JSON.stringify(data));
14801485
// let IDConv = data.recipient
@@ -1485,7 +1490,7 @@ export class AppComponent implements OnInit {
14851490
// pageUrl += IDConv + '/' + FullNameConv + '/' + Convtype
14861491
// }
14871492
// // replace(/\(/g, '%28').replace(/\)/g, '%29') -> used for the encoder of any round brackets
1488-
// this.router.navigateByUrl(pageUrl.replace(/\(/g, '%28').replace(/\)/g, '%29').replace( /#/g, "%23" ));
1493+
// this.router.navigateByUrl(pageUrl.replace(/\(/g, '%28').replace(/\)/g, '%29'));
14891494
};
14901495
});
14911496
}

src/app/pages/conversations-list/conversations-list.page.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -888,21 +888,21 @@ export class ConversationListPage implements OnInit {
888888
this.logger.log('[CONVS-LIST-PAGE] checkPlatformIsMobile(): ', checkPlatformIsMobile())
889889
this.logger.log('[CONVS-LIST-PAGE] DESKTOP (window < 768)', this.navService)
890890
this.logger.log('[CONVS-LIST-PAGE] navigateByUrl this.conversationSelected conversation_with_fullname ', this.conversationSelected)
891-
let pageUrl = 'conversation-detail/' + this.uidConvSelected + '/' + this.conversationSelected.conversation_with_fullname + '/' + converationType
891+
let pageUrl = 'conversation-detail/' + this.uidConvSelected + '/' + encodeURIComponent(this.conversationSelected.conversation_with_fullname) + '/' + converationType
892892
this.logger.log('[CONVS-LIST-PAGE] pageURL', pageUrl)
893893
// replace(/\(/g, '%28').replace(/\)/g, '%29') -> used for the encoder of any round brackets
894-
this.router.navigateByUrl(pageUrl.replace(/\(/g, '%28').replace(/\)/g, '%29').replace( /#/g, "%23" ), {replaceUrl: true})
894+
this.router.navigateByUrl(pageUrl.replace(/\(/g, '%28').replace(/\)/g, '%29'), {replaceUrl: true})
895895
} else {
896896
this.logger.log('[CONVS-LIST-PAGE] navigateByUrl this.conversationSelected conversation_with_fullname ', this.conversationSelected)
897897
this.logger.log('[CONVS-LIST-PAGE] checkPlatformIsMobile(): ', checkPlatformIsMobile())
898898
this.logger.log('[CONVS-LIST-PAGE] MOBILE (window >= 768) ', this.navService)
899899
let pageUrl = 'conversation-detail/' + this.uidConvSelected
900900
if (this.conversationSelected && this.conversationSelected.conversation_with_fullname) {
901-
pageUrl = 'conversation-detail/' + this.uidConvSelected + '/' + this.conversationSelected.conversation_with_fullname + '/' + converationType
901+
pageUrl = 'conversation-detail/' + this.uidConvSelected + '/' + encodeURIComponent(this.conversationSelected.conversation_with_fullname) + '/' + converationType
902902
}
903903
this.logger.log('[CONVS-LIST-PAGE] setUidConvSelected navigateByUrl--->: ', pageUrl)
904904
// replace(/\(/g, '%28').replace(/\)/g, '%29') -> used for the encoder of any round brackets
905-
this.router.navigateByUrl(pageUrl.replace(/\(/g, '%28').replace(/\)/g, '%29').replace( /#/g, "%23" ), {replaceUrl: true})
905+
this.router.navigateByUrl(pageUrl.replace(/\(/g, '%28').replace(/\)/g, '%29'), {replaceUrl: true})
906906
}
907907
}
908908

0 commit comments

Comments
 (0)