regression: fallback base url for redirection (#8075)
This commit is contained in:
parent
8853637e98
commit
d05c222d0a
3 changed files with 12 additions and 6 deletions
|
|
@ -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 === "/") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue