Skip to content

Commit

Permalink
fix: connectRouter using fragment (#428)
Browse files Browse the repository at this point in the history
* fix: update angular versions

* fix: change connectRouter to use router navigate with fragment

* fix: lint issue

---------

Co-authored-by: kim.tran <[email protected]>
Co-authored-by: Annika Nowak <[email protected]>
Co-authored-by: markuczy <[email protected]>
  • Loading branch information
4 people authored Aug 28, 2024
1 parent 3c3a248 commit 9e36673
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,16 @@ function connectMicroFrontendRouter(injector: Injector, warn = true): Subscripti

function connectRouter(router: Router): Subscription {
const initialUrl = `${location.pathname.substring(getLocation().deploymentPath.length)}${location.search}`
router.navigateByUrl(initialUrl)
router.navigate([initialUrl], { fragment: location.hash.substring(1) })
let lastUrl = initialUrl
let lastHash = location.hash
const observer = new EventsTopic()
return observer.pipe(filter((e) => e.type === 'navigated')).subscribe(() => {
const routerUrl = `${location.pathname.substring(getLocation().deploymentPath.length)}${location.search}`
if (routerUrl !== lastUrl) {
if (routerUrl !== lastUrl || location.hash !== lastHash) {
lastUrl = routerUrl
router.navigateByUrl(routerUrl)
lastHash = location.hash
router.navigate([routerUrl], { fragment: location.hash.substring(1) })
}
})
}
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9e36673

Please sign in to comment.