Skip to content

Commit

Permalink
fix: remove baseurl append on retry (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
olivervorasai authored Nov 10, 2021
1 parent a183b02 commit 7e1b54d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import destr from 'destr'
import { joinURL, withQuery } from 'ufo'
import { withBase, withQuery } from 'ufo'
import type { Fetch, RequestInfo, RequestInit, Response } from './types'
import { createFetchError } from './error'

Expand Down Expand Up @@ -68,7 +68,7 @@ export function createFetch ({ fetch }: CreateFetchOptions): $Fetch {
const $fetchRaw: $Fetch['raw'] = async function $fetchRaw (request, opts = {}) {
if (typeof request === 'string') {
if (opts.baseURL) {
request = joinURL(opts.baseURL, request)
request = withBase(request, opts.baseURL)
}
if (opts.params) {
request = withQuery(request, opts.params)
Expand Down
5 changes: 5 additions & 0 deletions test/index.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,9 @@ describe('ohmyfetch', () => {
expect(err.response?.data).to.deep.eq(err.data)
expect(err.request).to.equal(getURL('404'))
})

it('baseURL with retry', async () => {
const err = await $fetch('', { baseURL: getURL('404'), retry: 3 }).catch(err => err)
expect(err.request).to.equal(getURL('404'))
})
})

0 comments on commit 7e1b54d

Please sign in to comment.