Skip to content

Commit 298c3c0

Browse files
author
Your Name
committed
Fix lint
1 parent 3000408 commit 298c3c0

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

src/utils/request-queue.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,7 @@ class RequestQueue {
112112
}
113113
}
114114

115-
// Build security token header (mirrors Node SDK pattern)
116-
const headers = {};
117-
if (this.options.securityToken && typeof this.options.securityToken === 'string') {
118-
headers['x-cnstrc-token'] = this.options.securityToken;
119-
}
120-
if (this.options.userIp && typeof this.options.userIp === 'string') {
121-
headers['X-Forwarded-For'] = this.options.userIp;
122-
}
123-
if (this.options.userAgent && typeof this.options.userAgent === 'string') {
124-
headers['User-Agent'] = this.options.userAgent;
125-
}
115+
const headers = this.buildHeaders();
126116

127117
if (nextInQueue.method === 'GET') {
128118
request = fetch(nextInQueue.url, { headers, signal });
@@ -199,6 +189,21 @@ class RequestQueue {
199189
}
200190
}
201191

192+
// Build request headers from options
193+
buildHeaders() {
194+
const headers = {};
195+
if (this.options.securityToken && typeof this.options.securityToken === 'string') {
196+
headers['x-cnstrc-token'] = this.options.securityToken;
197+
}
198+
if (this.options.userIp && typeof this.options.userIp === 'string') {
199+
headers['X-Forwarded-For'] = this.options.userIp;
200+
}
201+
if (this.options.userAgent && typeof this.options.userAgent === 'string') {
202+
headers['User-Agent'] = this.options.userAgent;
203+
}
204+
return headers;
205+
}
206+
202207
// Read from queue and send requests to server
203208
send() {
204209
if (this.sendTrackingEvents) {

0 commit comments

Comments
 (0)