Skip to content

Commit

Permalink
fix(controller/finder): altering the beforeFind middleware to ensure …
Browse files Browse the repository at this point in the history
…redirection is blocked
  • Loading branch information
korgon committed Oct 6, 2023
1 parent 717339a commit 936e184
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions packages/snap-controller/src/Finder/FinderController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ export class FinderController extends AbstractController {
finder.controller.store.loading = false;
});

this.eventManager.on('beforeFind', async (finder: { controller: FinderController }, next: Next): Promise<void | boolean> => {
await next();

window.location.href = this.urlManager.href;
});

// attach config plugins and event middleware
this.use(this.config);

Expand Down Expand Up @@ -115,6 +109,9 @@ export class FinderController extends AbstractController {
await this.eventManager.fire('beforeFind', {
controller: this,
});

// redirect to configured URL after middleware completes
window.location.href = this.urlManager.href;
} catch (err: any) {
if (err?.message == 'cancelled') {
this.log.warn(`'beforeFind' middleware cancelled`);
Expand Down

0 comments on commit 936e184

Please sign in to comment.