regression: fallback base url for redirection (#8075)

This commit is contained in:
Aaryan Khandelwal
2025-11-07 16:10:52 +05:30
committed by GitHub
parent 8853637e98
commit d05c222d0a
3 changed files with 12 additions and 6 deletions
+4 -2
View File
@@ -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 === "/") {
+4 -2
View File
@@ -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 === "/") {
+4 -2
View File
@@ -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 === "/") {