From 988c6c31a9dccca00e95bba533e5dfed29c247a5 Mon Sep 17 00:00:00 2001
From: Stan Runge
- The money tracker is a private tool used only by the site owner. With the account holders' + Money (/trackers/money) is a private tool used only by the site owner. With the account holders' explicit consent, it reads account details, balances and booked transactions from Revolut through Enable Banking Oy, a licensed account information service provider. This data is used only to show the account holders their own finances. It is stored in a database on a server diff --git a/src/routes/projects/money-tracker/[...rest]/+server.ts b/src/routes/projects/money-tracker/[...rest]/+server.ts new file mode 100644 index 0000000..4f452f2 --- /dev/null +++ b/src/routes/projects/money-tracker/[...rest]/+server.ts @@ -0,0 +1,10 @@ +import { redirect } from '@sveltejs/kit'; +import type { RequestHandler } from './$types'; + +// Money moved from /projects/money-tracker to /trackers/money. Old links, and the Enable Banking +// redirect URL registered as /projects/money-tracker/bank-callback, keep working: 308 keeps the +// method, the subpath and the query string (?range=, ?code=&state=). +export const fallback: RequestHandler = ({ params, url }) => { + redirect(308, `/trackers/money${params.rest ? `/${params.rest}` : ''}${url.search}`); +}; +export const GET = fallback; diff --git a/src/routes/projects/money-tracker/[...rest]/redirect.test.ts b/src/routes/projects/money-tracker/[...rest]/redirect.test.ts new file mode 100644 index 0000000..466c205 --- /dev/null +++ b/src/routes/projects/money-tracker/[...rest]/redirect.test.ts @@ -0,0 +1,30 @@ +import { isRedirect } from '@sveltejs/kit'; +import { describe, expect, it } from 'vitest'; +import { fallback } from './+server'; + +function target(path: string, rest: string) { + try { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + fallback({ params: { rest }, url: new URL(`https://stanrunge.dev${path}`) } as any); + } catch (thrown) { + if (isRedirect(thrown)) return [thrown.status, thrown.location]; + throw thrown; + } + return null; +} + +describe('old money tracker URLs', () => { + it('redirects to /trackers/money, keeping subpath and query', () => { + expect(target('/projects/money-tracker?range=3y', '')).toEqual([ + 308, + '/trackers/money?range=3y' + ]); + expect(target('/projects/money-tracker/transactions?page=2', 'transactions')).toEqual([ + 308, + '/trackers/money/transactions?page=2' + ]); + expect( + target('/projects/money-tracker/bank-callback?state=s&code=abc-123', 'bank-callback') + ).toEqual([308, '/trackers/money/bank-callback?state=s&code=abc-123']); + }); +}); diff --git a/src/routes/terms/+page.svelte b/src/routes/terms/+page.svelte index 01e1045..6d8ee4b 100644 --- a/src/routes/terms/+page.svelte +++ b/src/routes/terms/+page.svelte @@ -22,10 +22,11 @@ You're responsible for activity on your account. Accounts that abuse the site may be removed. You can ask for your account to be deleted at any time.
-- The money tracker is a private tool for the site owner and household. Its bank connection is - read-only (account information via Enable Banking) and nothing shown in it is financial advice. + Money (/trackers/money) is a private tool for the site owner and household. Its bank connection + is read-only (account information via Enable Banking) and nothing shown in it is financial + advice.
diff --git a/src/routes/projects/money-tracker/+page.server.ts b/src/routes/trackers/money/+page.server.ts
similarity index 99%
rename from src/routes/projects/money-tracker/+page.server.ts
rename to src/routes/trackers/money/+page.server.ts
index 1df001e..0d51217 100644
--- a/src/routes/projects/money-tracker/+page.server.ts
+++ b/src/routes/trackers/money/+page.server.ts
@@ -31,7 +31,7 @@ import { error, redirect } from '@sveltejs/kit';
import type { Actions, PageServerLoad } from './$types';
export const load: PageServerLoad = async (event) => {
- if (!event.locals.user) redirect(303, '/login?returnTo=/projects/money-tracker');
+ if (!event.locals.user) redirect(303, '/login?returnTo=/trackers/money');
const user = requireAdmin(event);
const userId = user.id;
const [
diff --git a/src/routes/projects/money-tracker/+page.svelte b/src/routes/trackers/money/+page.svelte
similarity index 99%
rename from src/routes/projects/money-tracker/+page.svelte
rename to src/routes/trackers/money/+page.svelte
index a7b4d10..9463b79 100644
--- a/src/routes/projects/money-tracker/+page.svelte
+++ b/src/routes/trackers/money/+page.svelte
@@ -250,7 +250,7 @@
);
const link = document.createElement('a');
link.href = url;
- link.download = 'money-tracker-transactions.csv';
+ link.download = 'money-transactions.csv';
link.click();
setTimeout(() => URL.revokeObjectURL(url), 1000);
}
@@ -276,7 +276,7 @@
Personal finance {form.message}
@@ -138,7 +138,7 @@
Money tracker
+ Money
Transactions