From 4d6257af5080973cd69f639f4e1c38e3856df981 Mon Sep 17 00:00:00 2001 From: Cloud Date: Thu, 5 Sep 2019 12:01:44 +0800 Subject: [PATCH] feat: replace baseUrl to prefixUrl when got's next version (#2996) * enhance: replace baseUrl to prefixUrl when got's next version * test: baseUrl --- lib/utils/got.js | 3 +++ test/utils/got.js | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/utils/got.js b/lib/utils/got.js index 0b0449cdf..25891cee3 100644 --- a/lib/utils/got.js +++ b/lib/utils/got.js @@ -40,6 +40,9 @@ const custom = got.extend({ if (options.query) { options.searchParams = options.query; // for Got v11 after } + if (options.baseUrl) { + options.prefixUrl = options.baseUrl; // for Got next version + } }, ], }, diff --git a/test/utils/got.js b/test/utils/got.js index 1e1fd3a67..af8cff397 100644 --- a/test/utils/got.js +++ b/test/utils/got.js @@ -48,7 +48,8 @@ describe('got', () => { return [200, '{"code": 0}']; }); - const response1 = await got.post('http://rsshub.test/post', { + const response1 = await got.post('post', { + baseUrl: 'http://rsshub.test/', form: true, data: { test: 1,