Skip to content

Commit 6e492c2

Browse files
committed
feat: support the case where axiosConfig.urlPrefix is empty
1 parent a6d26bb commit 6e492c2

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/api.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
const METHODS_WITH_REQUEST_BODY = ['PUT', 'POST', 'DELETE', 'PATCH']
22

33
const createURL = (urlPrefix, url) =>
4-
url
5-
? url.startsWith('/')
6-
? url
7-
: (urlPrefix.endsWith('/')
8-
? urlPrefix
9-
: `${urlPrefix}/`)
10-
+ url
11-
: urlPrefix
4+
urlPrefix
5+
? url
6+
? url.startsWith('/')
7+
? url
8+
: (urlPrefix.endsWith('/')
9+
? urlPrefix
10+
: `${urlPrefix}/`)
11+
+ url
12+
: urlPrefix
13+
: url
1214

1315
function configToCaller(axios, urlPrefix, config) {
1416
// 如果配置非函数,则不需要每次调用接口都重新计算 URL

0 commit comments

Comments
 (0)