diff --git a/README.md b/README.md index e8e76a8..4dc77a6 100644 --- a/README.md +++ b/README.md @@ -244,6 +244,7 @@ Change Log - installation via jspm and loader support for System.js - support for Android 4.0-5.0 (no code changes required, now actively testing) - support for Safari 8, iOS 8.0 and 8.1 (no code changes required, now actively testing) +- raw configuration objects are retained by interceptors, config objects are no longer begotten - transient timeouts via config.transient on rest/interceptor/timeout, allows retry interceptor to wrap timeout - request.mixin properties attempt setting before before and after opening the request. Some browsers (IE) are sensitive to when the properties are set. - wire.js rest factory interceptors now wire configuration objects diff --git a/interceptor.js b/interceptor.js index 894778e..49da566 100644 --- a/interceptor.js +++ b/interceptor.js @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors + * Copyright 2012-2015 the original author or authors * @license MIT, see LICENSE.txt for details * * @author Scott Andrews @@ -109,7 +109,7 @@ target = handlers.client || defaultClient; } - config = initHandler(Object.create(config || {})); + config = initHandler(config || {}); function interceptedClient(request) { var context, meta; diff --git a/test/interceptor-test.js b/test/interceptor-test.js index 5b27455..dd8fe1d 100644 --- a/test/interceptor-test.js +++ b/test/interceptor-test.js @@ -1,5 +1,5 @@ /* - * Copyright 2013-2014 the original author or authors + * Copyright 2013-2015 the original author or authors * @license MIT, see LICENSE.txt for details * * @author Scott Andrews @@ -310,14 +310,12 @@ theInterceptor = interceptor({ request: function (request, config) { request.phase = 'request'; - refute.same(theConfig, config); - assert.same(theConfig.foo, config.foo); + assert.same(theConfig, config); return request; }, response: function (response, config) { response.phase = 'response'; - refute.same(theConfig, config); - assert.same(theConfig.foo, config.foo); + assert.same(theConfig, config); return response; } }); @@ -444,32 +442,29 @@ assert.same('default', response.id); }).otherwise(fail); }, - 'should initialize the config object, without modifying the provided object': function () { + 'should initialize the config object, modifying the provided object': function () { var theConfig, theInterceptor, client; theConfig = { foo: 'bar' }; theInterceptor = interceptor({ init: function (config) { - refute.same(theConfig, config); - assert.same('bar', config.foo); + assert.same(theConfig, config); config.bleep = 'bloop'; return config; }, request: function (request, config) { - refute.same(theConfig, config); - assert.same('bar', config.foo); - config.foo = 'not-bar'; - assert.same('bar', theConfig.foo); + assert.same(theConfig, config); request.phase = 'request'; return request; }, response: function (response, config) { - assert.same('not-bar', config.foo); - assert.same('bar', theConfig.foo); + assert.same(theConfig, config); response.phase = 'response'; return response; } }); + refute('bleep' in theConfig); client = theInterceptor(defaultClient, theConfig); + assert.same('bloop', theConfig.bleep); return client().then(function (response) { assert.same('request', response.request.phase); assert.same('response', response.phase);