fix: improper route gating (#596)
This commit is contained in:
1 parent
a8b65750ca
commit
9f4790326f
6 files changed
+25
-20
No files matched your search
@@ -1,21 +1,17 @@
|
||||
import { resolveRoute } from '$app/paths'
|
||||
import { profile } from '$lib/auth.svelte.js'
|
||||
import { error, redirect } from '@sveltejs/kit'
|
||||
|
||||
export function load({ params, url }) {
|
||||
export function load({ params }) {
|
||||
if (Number(params.instance)) {
|
||||
const split = url.pathname.split('/')
|
||||
|
||||
split.splice(
|
||||
2,
|
||||
0,
|
||||
`${encodeURIComponent(profile.data.instance)?.toLowerCase()}`,
|
||||
redirect(
|
||||
302,
|
||||
resolveRoute(`/post/[instance]/[id]`, {
|
||||
instance: profile.data.instance.toLowerCase(),
|
||||
id: params.instance,
|
||||
}),
|
||||
)
|
||||
|
||||
const newUrl = new URL(url)
|
||||
newUrl.pathname = split.join('/')
|
||||
|
||||
redirect(302, newUrl.toString())
|
||||
}
|
||||
|
||||
error(404, 'Not found')
|
||||
error(404)
|
||||
}
|
||||
Reference in new issue
Block a user