Skip to content

Commit

Permalink
Merge pull request #122 from mariofriz/feat/add-safe-link-support
Browse files Browse the repository at this point in the history
Add support for old safe send link format
  • Loading branch information
sisou authored Nov 19, 2023
2 parents 72e6960 + b4267eb commit 305f6e4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/router.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import VueRouter, { RouteConfig, Route, NavigationGuardNext } from 'vue-router';
import Vue from 'vue';
import { createNimiqRequestLink, parseNimiqSafeRequestLink, NimiqRequestLinkType } from '@nimiq/utils';
import { Component } from 'vue-router/types/router.d';

import { provide, inject } from '@vue/composition-api';
Expand Down Expand Up @@ -332,6 +333,18 @@ const routes: RouteConfig[] = [{
props: { modal: true },
meta: { column: Columns.ADDRESS },
}],
beforeEnter: (to, from, next) => {
if (from.fullPath === '/' && to.hash.startsWith('#_request/')) {
const parsed = parseNimiqSafeRequestLink(window.location.href);
if (!parsed) return next();
const path = createNimiqRequestLink(parsed.recipient, {
...parsed,
type: NimiqRequestLinkType.URI,
});
return next({ path, replace: true });
}
return next();
},
}, {
path: '/settings',
components: {
Expand Down

0 comments on commit 305f6e4

Please sign in to comment.