Skip to content

Commit

Permalink
fix: normalize URL before parsing (#3077)
Browse files Browse the repository at this point in the history
  • Loading branch information
srijans38 committed Oct 31, 2021
1 parent da991de commit b66afcc
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib/parse-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b66afcc

Please sign in to comment.