From dabbd63a0286344f48a11f99b7991f908696760e Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Wed, 14 Feb 2024 20:01:01 -0800 Subject: [PATCH] fix(web): update unauthorized share link handling (#7126) --- web/src/lib/utils.ts | 3 +-- web/src/routes/(user)/share/[key]/+page.ts | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/web/src/lib/utils.ts b/web/src/lib/utils.ts index c7c528052f..88b0f0650f 100644 --- a/web/src/lib/utils.ts +++ b/web/src/lib/utils.ts @@ -13,7 +13,6 @@ import { unlinkOAuthAccount, type UserResponseDto, } from '@immich/sdk'; -import { common } from '@immich/sdk/axios'; import { get } from 'svelte/store'; interface UpdateParamAction { @@ -91,7 +90,7 @@ const createUrl = (path: string, parameters?: Record) => { const url = new URL(path, 'https://example.com'); url.search = searchParameters.toString(); - return defaults.baseUrl + common.toPathString(url); + return defaults.baseUrl + url.pathname + url.search + url.hash; }; export const getAssetFileUrl = (...[assetId, isWeb, isThumb]: [string, boolean, boolean]) => { diff --git a/web/src/routes/(user)/share/[key]/+page.ts b/web/src/routes/(user)/share/[key]/+page.ts index a4327a832d..dd34b47e4b 100644 --- a/web/src/routes/(user)/share/[key]/+page.ts +++ b/web/src/routes/(user)/share/[key]/+page.ts @@ -1,8 +1,7 @@ import { getAssetThumbnailUrl } from '$lib/utils'; import { authenticate } from '$lib/utils/auth'; import { ThumbnailFormat, getMySharedLink } from '@immich/sdk'; -import { error as throwError } from '@sveltejs/kit'; -import type { AxiosError } from 'axios'; +import { error as throwError, type HttpError } from '@sveltejs/kit'; import type { PageLoad } from './$types'; export const load = (async ({ params }) => { @@ -25,7 +24,7 @@ export const load = (async ({ params }) => { } catch (error) { // handle unauthorized error // TODO this doesn't allow for 404 shared links anymore - if ((error as AxiosError).response?.status === 401) { + if ((error as HttpError).status === 401) { return { passwordRequired: true, sharedLinkKey: key,