Skip to content

Commit 2800d04

Browse files
authored
Merge pull request #31 from myosotys/master
Don't need to intercept when response is an array
2 parents 6c5c6c7 + 0fc4ed6 commit 2800d04

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

dist/angular-spring-data-rest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ angular.module("spring-data-rest").provider("SpringDataRestInterceptor",
406406

407407
return {
408408
response: function (response) {
409-
if(!angular.isObject(response.data)){
409+
if (!angular.isObject(response.data) || response.data instanceof Array){
410410
return response;
411411
}
412412
return SpringDataRestAdapter.process(response.data).then(function (processedResponse) {

dist/angular-spring-data-rest.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/angular-spring-data-rest-interceptor-provider.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ angular.module("spring-data-rest").provider("SpringDataRestInterceptor",
1717

1818
return {
1919
response: function (response) {
20-
if(!angular.isObject(response.data)){
20+
if (!angular.isObject(response.data) || response.data instanceof Array){
2121
return response;
2222
}
2323
return SpringDataRestAdapter.process(response.data).then(function (processedResponse) {

test/angular-spring-data-rest-interceptor-provider.spec.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,18 @@ describe("if the spring data rest interceptor is added", function () {
146146
expect(data).toBe(responseString);
147147
});
148148

149+
it(" it must not execute when a response is of type array", function () {
150+
var linkHref = "http://localhost:8080/categories";
151+
var responseString = [{"test":"test"}];
152+
this.httpBackend.whenGET(linkHref).respond(200, responseString);
153+
this.httpBackend.expectGET(linkHref);
154+
155+
var data = $http.get(linkHref).then(function(response){
156+
data = response.data;
157+
});
158+
159+
this.httpBackend.flush();
160+
expect(angular.equals(data,responseString)).toBeTruthy();
161+
});
162+
149163
});

0 commit comments

Comments
 (0)