Skip to content

Commit 8dca580

Browse files
committed
1.7.1
1 parent a5c23ed commit 8dca580

File tree

4 files changed

+30
-7
lines changed

4 files changed

+30
-7
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ const client = new Client({
147147

148148
```ts
149149
import { Client } from "jira.js";
150-
150+
151151
const client = new Client({
152152
host: "https://jira.somehost.com",
153153
middlewares: {
@@ -174,6 +174,10 @@ Can't find what you need in the readme? Check out our documentation here: https:
174174

175175
## Latest version changelog
176176

177+
### 1.7.1
178+
179+
- FIX: Headers fixes
180+
177181
### 1.7.0
178182

179183
- IMPROVEMENT: Readme examples updated

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jira.js",
3-
"version": "1.7.0",
3+
"version": "1.7.1",
44
"main": "out/index.js",
55
"types": "out/index.d.ts",
66
"repository": "https://github.com/MrRefactoring/jira.js.git",

src/helpers/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@ import * as jwt from 'atlassian-jwt';
33
import * as url from 'url';
44
import { Config } from '../config';
55

6+
export const removeEmptyValues = (obj: { [key: string]: unknown }) => Object.entries(obj)
7+
.forEach(([key, val]) => {
8+
if (val && typeof val === 'object') {
9+
// @ts-ignore
10+
removeEmptyValues(val);
11+
} else if (val == null) {
12+
// eslint-disable-next-line no-param-reassign
13+
delete obj[key];
14+
} else {
15+
console.log(obj);
16+
}
17+
});
18+
619
export const getAuthentication = (
720
config: Config,
821
request: AxiosRequestConfig,

src/index.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import axios, { AxiosInstance, AxiosRequestConfig } from 'axios';
44
import { Callback } from './callback';
55
import { Config } from './config';
6-
import { getAuthentication } from './helpers';
6+
import { getAuthentication, removeEmptyValues } from './helpers';
77
import {
88
ApplicationRoles,
99
AppProperties,
@@ -188,14 +188,18 @@ export class Client {
188188
private requestInstance: AxiosInstance;
189189

190190
constructor(private readonly config: Config) {
191+
const headers = {
192+
...config.baseRequestConfig?.headers,
193+
'x-atlassian-force-account-id': config.strictGDPR,
194+
};
195+
196+
removeEmptyValues(headers);
197+
191198
this.requestInstance = axios.create({
192199
timeout: config.timeout,
193200
...config.baseRequestConfig,
194201
baseURL: config.host,
195-
headers: {
196-
...config.baseRequestConfig?.headers,
197-
'x-atlassian-force-account-id': config.strictGDPR,
198-
},
202+
headers,
199203
});
200204

201205
this.applicationRoles = new ApplicationRoles(this);
@@ -294,6 +298,8 @@ export class Client {
294298
...request.headers,
295299
};
296300

301+
removeEmptyValues(request.headers);
302+
297303
const response = await this.requestInstance.request(request);
298304

299305
const callbackResponseHandler = callback && ((data: any): void => callback(null, data));

0 commit comments

Comments
 (0)