Skip to content

armgit / plane

Public Imported from GitHub
0

πŸ”₯πŸ”₯πŸ”₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.

regression: fallback base url for redirection (#8075)

Aaryan Khandelwald05c222d0a2e
diff --git a/apps/admin/app/compat/next/helper.ts b/apps/admin/app/compat/next/helper.ts
index fe1a984460..c046998702 100644
--- a/apps/admin/app/compat/next/helper.ts
+++ b/apps/admin/app/compat/next/helper.ts
@@ -5,8 +5,10 @@
*/
export function ensureTrailingSlash(url: string): string {
try {
- // Handle relative URLs by creating a URL object with a dummy base
- const urlObj = new URL(url, "http://dummy.com");
+ const fallbackBaseUrl =
+ typeof window !== "undefined" && window.location.origin ? window.location.origin : "http://dummy.com";
+ // Handle relative URLs by creating a URL object with a fallback base URL
+ const urlObj = new URL(url, fallbackBaseUrl);
// Don't modify root path
if (urlObj.pathname === "/") {
diff --git a/apps/space/app/compat/next/helper.ts b/apps/space/app/compat/next/helper.ts
index fe1a984460..c046998702 100644
--- a/apps/space/app/compat/next/helper.ts
+++ b/apps/space/app/compat/next/helper.ts
@@ -5,8 +5,10 @@
*/
export function ensureTrailingSlash(url: string): string {
try {
- // Handle relative URLs by creating a URL object with a dummy base
- const urlObj = new URL(url, "http://dummy.com");
+ const fallbackBaseUrl =
+ typeof window !== "undefined" && window.location.origin ? window.location.origin : "http://dummy.com";
+ // Handle relative URLs by creating a URL object with a fallback base URL
+ const urlObj = new URL(url, fallbackBaseUrl);
// Don't modify root path
if (urlObj.pathname === "/") {
diff --git a/apps/web/app/compat/next/helper.ts b/apps/web/app/compat/next/helper.ts
index fe1a984460..c046998702 100644
--- a/apps/web/app/compat/next/helper.ts
+++ b/apps/web/app/compat/next/helper.ts
@@ -5,8 +5,10 @@
*/
export function ensureTrailingSlash(url: string): string {
try {
- // Handle relative URLs by creating a URL object with a dummy base
- const urlObj = new URL(url, "http://dummy.com");
+ const fallbackBaseUrl =
+ typeof window !== "undefined" && window.location.origin ? window.location.origin : "http://dummy.com";
+ // Handle relative URLs by creating a URL object with a fallback base URL
+ const urlObj = new URL(url, fallbackBaseUrl);
// Don't modify root path
if (urlObj.pathname === "/") {