Skip to content

Commit

Permalink
capa Explorer Web: improve url navigation (#2425)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
s-ff and mr-tz authored Oct 1, 2024
1 parent 3e8bed1 commit 16eae70
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
- replace tabulate, tqdm, and termcolor with rich #2374 @s-ff
- dynamic: emit complete features for A/W APIs #2409 @mike-hunhoff

### capa explorer IDA Pro plugin
### capa Explorer Web
- improve navigation in capa Explorer Web @s-ff #2425

### capa Explorer IDA Pro plugin

### Development

Expand Down
18 changes: 13 additions & 5 deletions web/explorer/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" });
}
}
}
},
Expand Down

0 comments on commit 16eae70

Please sign in to comment.