From b66afcc5cc7478473618a90bad90d9bcd17f7847 Mon Sep 17 00:00:00 2001 From: Srijan Sharma Date: Sun, 31 Oct 2021 15:05:02 +0530 Subject: [PATCH] fix: normalize URL before parsing (#3077) --- src/lib/parse-url.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib/parse-url.ts b/src/lib/parse-url.ts index cee4c5375a..fbda0b9d9d 100644 --- a/src/lib/parse-url.ts +++ b/src/lib/parse-url.ts @@ -13,6 +13,11 @@ export interface InternalUrl { export default function parseUrl(url?: string): InternalUrl { const defaultUrl = new URL("http://localhost:3000/api/auth") + + if (url && !url.startsWith("http")) { + url = `https://${url}` + } + const _url = new URL(url ?? defaultUrl) const path = (_url.pathname === "/" ? defaultUrl.pathname : _url.pathname) // Remove trailing slash