diff --git a/lib/api/controllers/migration/importFromHTMLFile.ts b/lib/api/controllers/migration/importFromHTMLFile.ts index b2b58a1..59a2787 100644 --- a/lib/api/controllers/migration/importFromHTMLFile.ts +++ b/lib/api/controllers/migration/importFromHTMLFile.ts @@ -63,7 +63,8 @@ async function processBookmarks( ) as Element; if (collectionName) { - const collectionNameContent = (collectionName.children[0] as TextNode)?.content; + const collectionNameContent = (collectionName.children[0] as TextNode) + ?.content; if (collectionNameContent) { collectionId = await createCollection( userId, @@ -274,4 +275,3 @@ function processNodes(nodes: Node[]) { nodes.forEach(findAndProcessDL); return nodes; } - diff --git a/lib/client/getPublicCollectionData.ts b/lib/client/getPublicCollectionData.ts index 283733b..a8a74a3 100644 --- a/lib/client/getPublicCollectionData.ts +++ b/lib/client/getPublicCollectionData.ts @@ -9,6 +9,9 @@ const getPublicCollectionData = async ( ) => { const res = await fetch("/api/v1/public/collections/" + collectionId); + if (res.status === 400) + return { response: "Collection not found.", status: 400 }; + const data = await res.json(); setData(data.response); diff --git a/next-i18next.config.js b/next-i18next.config.js index 06c3d23..b78b3b8 100644 --- a/next-i18next.config.js +++ b/next-i18next.config.js @@ -2,7 +2,7 @@ module.exports = { i18n: { defaultLocale: "en", - locales: ["en","it"], + locales: ["en", "it"], }, reloadOnPrerender: process.env.NODE_ENV === "development", }; diff --git a/pages/public/collections/[id].tsx b/pages/public/collections/[id].tsx index c2229dc..ab7fd42 100644 --- a/pages/public/collections/[id].tsx +++ b/pages/public/collections/[id].tsx @@ -71,7 +71,13 @@ export default function PublicCollections() { useEffect(() => { if (router.query.id) { - getPublicCollectionData(Number(router.query.id), setCollection); + getPublicCollectionData(Number(router.query.id), setCollection).then( + (res) => { + if (res.status === 400) { + router.push("/dashboard"); + } + } + ); } }, [collections]);