fix: append protocol if empty - resolved #1927

This commit is contained in:
liyasthomas
2021-11-16 09:25:25 +05:30
parent 30327e8d27
commit 6813be47f0

View File

@@ -124,6 +124,13 @@ function getCodegenAuth(
}
}
function addhttps(url: string) {
if (!/^(?:f|ht)tps?:\/\//.test(url)) {
url = "https://" + url
}
return url
}
function getCodegenGeneralRESTInfo(
request: EffectiveHoppRESTRequest
): Pick<
@@ -137,7 +144,12 @@ function getCodegenGeneralRESTInfo(
| "params"
| "headers"
> {
const urlObj = new URL(request.effectiveFinalURL)
let urlObj: URL
try {
urlObj = new URL(request.effectiveFinalURL)
} catch (error) {
urlObj = new URL(addhttps(request.effectiveFinalURL))
}
request.effectiveFinalParams.forEach(({ key, value }) => {
urlObj.searchParams.append(key, value)
})