File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -73,11 +73,7 @@ export class HttpService {
7373 ...args : any [ ]
7474 ) {
7575 return new Observable < AxiosResponse < T > > ( subscriber => {
76- let config : AxiosRequestConfig = args [ args . length - 1 ] ;
77- if ( ! config ) {
78- config = { } ;
79- args [ args . length - 1 ] = config ;
80- }
76+ const config = args [ args . length - 1 ] ? { ...args [ args . length - 1 ] } : { } ;
8177
8278 let cancelSource : CancelTokenSource ;
8379 if ( ! config . cancelToken ) {
Original file line number Diff line number Diff line change 1+ import { expect } from 'chai' ;
2+ import { HttpService } from '../../http/http.service' ;
3+ import { AxiosRequestConfig , AxiosInstance } from 'axios' ;
4+
5+ describe ( 'HttpService' , ( ) => {
6+ it ( 'should not mutate user-given axios options object' , ( ) => {
7+ const http = new HttpService ( { get : ( ) => Promise . resolve ( ) } as any ) ;
8+ const options : AxiosRequestConfig = { } ;
9+
10+ http
11+ . get ( '/' , options )
12+ . toPromise ( )
13+ . then ( ( ) => {
14+ expect ( options . cancelToken ) . to . be . undefined ;
15+ } ) ;
16+ } ) ;
17+ } ) ;
You can’t perform that action at this time.
0 commit comments