Skip to content

Commit

Permalink
Merge pull request #946 from MuckRock/945-forward-queries
Browse files Browse the repository at this point in the history
  • Loading branch information
eyeseast authored Dec 4, 2024
2 parents e7f7c75 + fc2b1d0 commit 3dcfab5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/routes/(app)/+page.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { redirect } from "@sveltejs/kit";
import { searchUrl, userDocs } from "$lib/utils/search";
import { userDocs } from "$lib/utils/search";

export async function load({ parent }) {
export async function load({ parent, url }) {
const { me } = await parent();
const u = new URL(url);

if (me) {
return redirect(302, searchUrl(userDocs(me)));
u.pathname = "/documents/";
u.searchParams.set("q", userDocs(me));
return redirect(302, u);
}

return redirect(302, "/home/");
u.pathname = "/home/";
return redirect(302, u);
}
9 changes: 7 additions & 2 deletions src/routes/(app)/app/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

import { redirect } from "@sveltejs/kit";

export function load() {
return redirect(302, "/");
export function load({ url }) {
const u = new URL(url);

// change the path but preserve other parts of the URL
u.pathname = "/documents/";

return redirect(302, u);
}

0 comments on commit 3dcfab5

Please sign in to comment.