mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2025-08-22 13:49:13 +08:00
Fix linting
This commit is contained in:
parent
b708d5ba60
commit
e4ae385d1a
@ -239,11 +239,11 @@ it('HttpClient does basic https get request when bypass proxy', async () => {
|
|||||||
|
|
||||||
it('HttpClient bypasses proxy for loopback addresses (localhost, ::1, 127.*)', async () => {
|
it('HttpClient bypasses proxy for loopback addresses (localhost, ::1, 127.*)', async () => {
|
||||||
// setup a server listening on localhost:8091
|
// setup a server listening on localhost:8091
|
||||||
var server = http.createServer(function (request, response) {
|
const server = http.createServer(function(request, response) {
|
||||||
response.writeHead(200);
|
response.writeHead(200)
|
||||||
request.pipe(response);
|
request.pipe(response)
|
||||||
});
|
})
|
||||||
await server.listen(8091)
|
server.listen(8091)
|
||||||
try {
|
try {
|
||||||
process.env['http_proxy'] = _proxyUrl
|
process.env['http_proxy'] = _proxyUrl
|
||||||
const httpClient = new httpm.HttpClient()
|
const httpClient = new httpm.HttpClient()
|
||||||
@ -252,12 +252,11 @@ it('HttpClient bypasses proxy for loopback addresses (localhost, ::1, 127.*)', a
|
|||||||
)
|
)
|
||||||
expect(res.message.statusCode).toBe(200)
|
expect(res.message.statusCode).toBe(200)
|
||||||
const body: string = await res.readBody()
|
const body: string = await res.readBody()
|
||||||
expect(body).toEqual('');
|
expect(body).toEqual('')
|
||||||
// proxy at _proxyUrl was ignored
|
// proxy at _proxyUrl was ignored
|
||||||
expect(_proxyConnects).toEqual([])
|
expect(_proxyConnects).toEqual([])
|
||||||
}
|
} finally {
|
||||||
finally {
|
server.close()
|
||||||
await server.close()
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -74,5 +74,9 @@ export function checkBypass(reqUrl: URL): boolean {
|
|||||||
|
|
||||||
function isLoopbackAddress(host: string): boolean {
|
function isLoopbackAddress(host: string): boolean {
|
||||||
const hostUpper = host.toUpperCase()
|
const hostUpper = host.toUpperCase()
|
||||||
return hostUpper === 'LOCALHOST' || hostUpper.startsWith('127.') || hostUpper.startsWith('::1')
|
return (
|
||||||
|
hostUpper === 'LOCALHOST' ||
|
||||||
|
hostUpper.startsWith('127.') ||
|
||||||
|
hostUpper.startsWith('::1')
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user