Comparing version 0.6.2 to 0.7.0
22
index.js
@@ -10,4 +10,4 @@ /** | ||
const http = require('http') | ||
const url = require('url') | ||
const { Server, createServer } = require('http') | ||
const { URL } = require('url') | ||
@@ -30,17 +30,15 @@ const axios = require('axios').default | ||
const createAdapter = handler => config => new Promise((resolve, reject) => { | ||
const urlObject = url.parse(config.url || '') | ||
const url = new URL(config.url || '', 'http://axiosist/') | ||
// Forcely set protocol to HTTP | ||
urlObject.protocol = 'http:' | ||
urlObject.slashes = true | ||
url.protocol = 'http' | ||
const host = urlObject.host | ||
delete urlObject.host | ||
urlObject.hostname = '127.0.0.1' | ||
const host = url.host | ||
url.host = '127.0.0.1' | ||
// Apply original host to request header | ||
if (host != null && config.headers.host == null) { | ||
if (host !== 'axiosist' && config.headers.host == null) { | ||
config.headers.host = host | ||
} | ||
const server = handler instanceof http.Server ? handler : http.createServer(handler) | ||
const server = handler instanceof Server ? handler : createServer(handler) | ||
const listening = server.listening | ||
@@ -56,4 +54,4 @@ | ||
const address = /** @type {AddressInfo} */(server.address()) | ||
urlObject.port = address.port.toString() | ||
config.url = url.format(urlObject) | ||
url.port = address.port.toString() | ||
config.url = url.toString() | ||
return defaultAdapter(config) | ||
@@ -60,0 +58,0 @@ }) |
{ | ||
"name": "axiosist", | ||
"version": "0.6.2", | ||
"version": "0.7.0", | ||
"description": "Convert node.js request handler to axios adapter", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8216
75