fix(nuxt): throw error on protocol relative path in useFetch (#20052)

This commit is contained in:
Aleksandar Trpkovski 2023-04-05 08:04:38 +10:00 committed by GitHub
parent ab9f33a648
commit 1ae30ba474
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -60,6 +60,7 @@ export function useFetch<
if (!request) {
throw new Error('[nuxt] [useFetch] request is missing.')
}
const key = _key === autoKey ? '$f' + _key : _key
const _request = computed(() => {
@ -70,6 +71,10 @@ export function useFetch<
return unref(r)
})
if (!opts.baseURL && typeof _request.value === 'string' && _request.value.startsWith('//')) {
throw new Error('[nuxt] [useFetch] the request URL must not start with "//".')
}
const {
server,
lazy,