Skip to content

Commit 6f82570

Browse files
authored
fix(module): always set protocol to https when https: true is set (#344)
1 parent b6f88ae commit 6f82570

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/module.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function axiosModule (_moduleOptions) {
8989

9090
// Convert http:// to https:// if https option is on
9191
if (options.https === true) {
92-
const https = s => s.includes('//localhost:') ? s : s.replace('http://', 'https://')
92+
const https = s => s.replace('http://', 'https://')
9393
options.baseURL = https(options.baseURL)
9494
options.browserBaseURL = https(options.browserBaseURL)
9595
}

test/axios.test.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ const testSuite = () => {
2929
expect(addTemplate).toBeDefined()
3030
const call = addTemplate.mock.calls.find(args => args[0].src.includes('plugin.js'))
3131
const options = call[0].options
32-
expect(options.baseURL.toString()).toBe('http://localhost:3000/test_api')
32+
const proto = options.https ? 'https' : 'http'
33+
expect(options.baseURL.toString()).toBe(`${proto}://localhost:3000/test_api`)
3334
expect(options.browserBaseURL.toString()).toBe('/test_api')
3435
})
3536

0 commit comments

Comments
 (0)