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 {
|
export function ensureTrailingSlash(url: string): string {
|
||||||
try {
|
try {
|
||||||
// Handle relative URLs by creating a URL object with a dummy base
|
const fallbackBaseUrl =
|
||||||
const urlObj = new URL(url, "http://dummy.com");
|
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
|
// Don't modify root path
|
||||||
if (urlObj.pathname === "/") {
|
if (urlObj.pathname === "/") {
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,10 @@
|
||||||
*/
|
*/
|
||||||
export function ensureTrailingSlash(url: string): string {
|
export function ensureTrailingSlash(url: string): string {
|
||||||
try {
|
try {
|
||||||
// Handle relative URLs by creating a URL object with a dummy base
|
const fallbackBaseUrl =
|
||||||
const urlObj = new URL(url, "http://dummy.com");
|
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
|
// Don't modify root path
|
||||||
if (urlObj.pathname === "/") {
|
if (urlObj.pathname === "/") {
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,10 @@
|
||||||
*/
|
*/
|
||||||
export function ensureTrailingSlash(url: string): string {
|
export function ensureTrailingSlash(url: string): string {
|
||||||
try {
|
try {
|
||||||
// Handle relative URLs by creating a URL object with a dummy base
|
const fallbackBaseUrl =
|
||||||
const urlObj = new URL(url, "http://dummy.com");
|
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
|
// Don't modify root path
|
||||||
if (urlObj.pathname === "/") {
|
if (urlObj.pathname === "/") {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue