Skip to content

fix(module): always set protocol to https when https: true is set #344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function axiosModule (_moduleOptions) {

// Convert http:// to https:// if https option is on
if (options.https === true) {
const https = s => s.includes('//localhost:') ? s : s.replace('http://', 'https://')
const https = s => s.replace('http://', 'https://')
options.baseURL = https(options.baseURL)
options.browserBaseURL = https(options.browserBaseURL)
}
Expand Down
3 changes: 2 additions & 1 deletion test/axios.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ const testSuite = () => {
expect(addTemplate).toBeDefined()
const call = addTemplate.mock.calls.find(args => args[0].src.includes('plugin.js'))
const options = call[0].options
expect(options.baseURL.toString()).toBe('http://localhost:3000/test_api')
const proto = options.https ? 'https' : 'http'
expect(options.baseURL.toString()).toBe(`${proto}://localhost:3000/test_api`)
expect(options.browserBaseURL.toString()).toBe('/test_api')
})

Expand Down