Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Commit

Permalink
it's pretty now and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanmacfarlane committed Apr 23, 2020
1 parent fbd1377 commit 943067f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
24 changes: 12 additions & 12 deletions __tests__/basics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,47 +181,47 @@ describe('basics', () => {

it('does not pass auth with diff hostname redirects', async done => {
let headers = {
"accept": "application/json",
"authorization": "shhh"
accept: 'application/json',
authorization: 'shhh'
}
let res: httpm.HttpClientResponse = await _http.get(
'https://httpbin.org/redirect-to?url=' +
encodeURIComponent('https://www.httpbin.org/get'),
headers
headers
)

expect(res.message.statusCode).toBe(200)
let body: string = await res.readBody()
let obj: any = JSON.parse(body)
// httpbin "fixes" the casing
expect(obj.headers["Authorization"]).toBeUndefined()
expect(obj.headers["authorization"]).toBeUndefined()
expect(obj.headers['Authorization']).toBeUndefined()
expect(obj.headers['authorization']).toBeUndefined()
expect(obj.url).toBe('https://www.httpbin.org/get')

done()
})

it('does not pass Auth with diff hostname redirects', async done => {
let headers = {
"Accept": "application/json",
"Authorization": "shhh"
Accept: 'application/json',
Authorization: 'shhh'
}
let res: httpm.HttpClientResponse = await _http.get(
'https://httpbin.org/redirect-to?url=' +
encodeURIComponent('https://www.httpbin.org/get'),
headers
headers
)

expect(res.message.statusCode).toBe(200)
let body: string = await res.readBody()
let obj: any = JSON.parse(body)
// httpbin "fixes" the casing
expect(obj.headers["Authorization"]).toBeUndefined()
expect(obj.headers["authorization"]).toBeUndefined()
expect(obj.headers['Authorization']).toBeUndefined()
expect(obj.headers['authorization']).toBeUndefined()
expect(obj.url).toBe('https://www.httpbin.org/get')

done()
})
})

it('does basic head request', async done => {
let res: httpm.HttpClientResponse = await _http.head(
Expand Down
6 changes: 3 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,10 @@ export class HttpClient {

// strip authorization header if redirected to a different hostname
if (parsedRedirectUrl.hostname !== parsedUrl.hostname) {
for(let header in headers){
for (let header in headers) {
// header names are case insensitive
if (header.toLowerCase() === "authorization") {
delete headers[header]
if (header.toLowerCase() === 'authorization') {
delete headers[header]
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@actions/http-client",
"version": "1.0.7",
"version": "1.0.8",
"description": "Actions Http Client",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 943067f

Please sign in to comment.