fix: append protocol if empty - resolved #1927
This commit is contained in:
parent
30327e8d27
commit
6813be47f0
1 changed files with 13 additions and 1 deletions
|
|
@ -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)
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue