Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

fix library redirects

Steven Teyc4ba300ff840
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/library/header.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/library/header.tsx
index def6b8c587..b033dac090 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/library/header.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/library/header.tsx
@@ -2,7 +2,7 @@
import useWorkspace from "@/lib/swr/use-workspace";
import { TabSelect } from "@dub/ui";
-import { useRouter, useSelectedLayoutSegment } from "next/navigation";
+import { redirect, useRouter, useSelectedLayoutSegment } from "next/navigation";
export default function LibraryHeader() {
const router = useRouter();
@@ -11,6 +11,12 @@ export default function LibraryHeader() {
const selectedLayoutSegment = useSelectedLayoutSegment();
const page = selectedLayoutSegment === null ? "" : selectedLayoutSegment;
+ if (selectedLayoutSegment === null) {
+ redirect(
+ `/${slug}/settings/library/${flags?.linkFolders ? "folders" : "tags"}`,
+ );
+ }
+
return (
<div className="border-b border-gray-200">
<h1 className="text-2xl font-semibold tracking-tight text-black">
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/library/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/library/page.tsx
new file mode 100644
index 0000000000..485a08ad85
--- /dev/null
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/library/page.tsx
@@ -0,0 +1,3 @@
+export default function LibraryPage() {
+ return <></>;
+}
diff --git a/apps/web/app/app.dub.co/(redirects)/[slug]/settings/tags/page.tsx b/apps/web/app/app.dub.co/(redirects)/[slug]/settings/tags/page.tsx
new file mode 100644
index 0000000000..c8b274204f
--- /dev/null
+++ b/apps/web/app/app.dub.co/(redirects)/[slug]/settings/tags/page.tsx
@@ -0,0 +1,11 @@
+import { redirect } from "next/navigation";
+
+export default function OldWorkspaceTags({
+ params,
+}: {
+ params: {
+ slug: string;
+ };
+}) {
+ redirect(`/${params.slug}/settings/library/tags`);
+}
diff --git a/apps/web/lib/middleware/utils/app-redirect.ts b/apps/web/lib/middleware/utils/app-redirect.ts
index 771cf44522..a79a699db3 100644
--- a/apps/web/lib/middleware/utils/app-redirect.ts
+++ b/apps/web/lib/middleware/utils/app-redirect.ts
@@ -5,11 +5,7 @@ const APP_REDIRECTS = {
};
export const appRedirect = (path: string) => {
- // Use a regex to match both "/settings/library" and "/settings/tags"
- const libraryTagsRegex = /\/settings\/(library|tags)$/;
- if (libraryTagsRegex.test(path)) {
- return path.replace(libraryTagsRegex, "/settings/library/tags");
- } else if (APP_REDIRECTS[path]) {
+ if (APP_REDIRECTS[path]) {
return APP_REDIRECTS[path];
}
return null;