File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -258,8 +258,7 @@ export class ApiRequest {
258258 method : HttpMethod ,
259259 body : object | object [ ] | null ,
260260 ) : Promise < Headers > {
261- const userAgent =
262- clientData . userAgent ?? `node-lokalise-api/${ await getVersion ( ) } ` ;
261+ const userAgent = clientData . userAgent ?. trim ( ) || `node-lokalise-api/${ await getVersion ( ) } ` ;
263262 const headers = new Headers ( {
264263 Accept : "application/json" ,
265264 "User-Agent" : userAgent ,
Original file line number Diff line number Diff line change @@ -30,6 +30,18 @@ describe("LokaliseApi", () => {
3030 expect ( client . clientData . enableCompression ) . to . be . false ;
3131 expect ( client . clientData . version ) . to . eq ( "api2" ) ;
3232 } ) ;
33+
34+ it ( "is expected to contain custom user-agent" , ( ) => {
35+ const client = new LokaliseApi ( {
36+ apiKey : process . env . API_KEY ,
37+ header : "Authorization" ,
38+ userAgent : "CustomUserAgent/1.0" ,
39+ } ) ;
40+ expect ( client . clientData . token ) . to . eq ( process . env . API_KEY ) ;
41+ expect ( client . clientData . enableCompression ) . to . be . false ;
42+ expect ( client . clientData . version ) . to . eq ( "api2" ) ;
43+ expect ( client . clientData . userAgent ) . to . eq ( "CustomUserAgent/1.0" ) ;
44+ } ) ;
3345} ) ;
3446
3547describe ( "LokaliseApi host" , ( ) => {
You can’t perform that action at this time.
0 commit comments