Skip to content

Commit

Permalink
fix: fix redirect to shorter username page when visiting user subpage.
Browse files Browse the repository at this point in the history
  • Loading branch information
zicklag committed Jan 9, 2025
1 parent 75068d9 commit 721bfdf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/lib/themes/weird.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import AvatarEditor from '$lib/components/avatar/editor.svelte';
import EditLinks from '$lib/components/pubpage-admin/edit-links.svelte';
import type { Profile } from '$lib/leaf/profile';
import { usernames } from '$lib/usernames/client';
import { renderMarkdownSanitized } from '$lib/utils/markdown';
import type { Snippet } from 'svelte';
Expand Down Expand Up @@ -203,8 +204,13 @@
<section class="links">
<h2>Pages</h2>
{#each pages as link}
<a href={`${env.PUBLIC_URL}/${$page.params.username}/${link.slug}`} target="_blank" class="link">
{link.name || `${env.PUBLIC_URL}/${$page.params.username}/${link.slug}`}
<a
href={`${env.PUBLIC_URL}/${usernames.shortNameOrDomain($page.params.username)}/${link.slug}`}
target="_blank"
class="link"
>
{link.name ||
`${env.PUBLIC_URL}/${usernames.shortNameOrDomain($page.params.username)}/${link.slug}`}
</a>
{/each}
</section>
Expand Down
4 changes: 2 additions & 2 deletions src/routes/(app)/[username]/+layout.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { base32Encode } from 'leaf-proto';
import { billing, type UserSubscriptionInfo } from '$lib/billing';
import { verifiedLinks } from '$lib/verifiedLinks';

export const load: LayoutServerLoad = async ({ fetch, params, request }) => {
export const load: LayoutServerLoad = async ({ fetch, params, request, url }) => {
const username = usernames.shortNameOrDomain(params.username!);
if (username != params.username) {
return redirect(302, `/${username}`);
return redirect(302, `/${username}/${url.pathname.split('/').slice(2).join('/')}`);
}

const fullUsername = usernames.fullDomain(params.username!);
Expand Down

0 comments on commit 721bfdf

Please sign in to comment.