mirror of
https://github.com/mandiant/capa.git
synced 2025-12-12 07:40:38 -08:00
capa Explorer Web: improve url navigation (#2425)
* explorer web: improve url navigation This commit enhances the navigation guard for the /analysis route to provide a better user experience when loading data from a URL: Previously: users browsing to /analysis were always redirected to the homepage (/). With this commit: - If a user accesses /analysis without an rdoc parameter, they are still redirected to the homepage. - If a user accesses /analysis with an rdoc parameter, the following occurs: The user is redirected to the homepage (/) and the rdoc parameter is preserved in the URL, capa Explorer Web then loads the rdoc from URL. --------- Co-authored-by: Moritz <mr-tz@users.noreply.github.com>
This commit is contained in:
@@ -18,12 +18,20 @@ const router = createRouter({
|
||||
name: "analysis",
|
||||
component: AnalysisView,
|
||||
beforeEnter: (to, from, next) => {
|
||||
if (rdocStore.data.value === null) {
|
||||
// No rdoc loaded, redirect to home page
|
||||
next({ name: "home" });
|
||||
} else {
|
||||
// rdoc is loaded, proceed to analysis page
|
||||
// check if rdoc is loaded
|
||||
if (rdocStore.data.value !== null) {
|
||||
// rdocStore.data already contains the rdoc json - continue
|
||||
next();
|
||||
} else {
|
||||
// rdoc is not loaded, check if the rdoc query param is set in the URL
|
||||
const rdocUrl = to.query.rdoc;
|
||||
if (rdocUrl) {
|
||||
// query param is set - try to load the rdoc from the homepage
|
||||
next({ name: "home", query: { rdoc: rdocUrl } });
|
||||
} else {
|
||||
// no query param is set - go back home
|
||||
next({ name: "home" });
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user