@@ -6,6 +6,9 @@ var _extend = require('lodash/extend');
66var _transform = require ( 'lodash/transform' ) ;
77var Inflector = require ( './inflector' ) ;
88
9+ const ancestrySeparator = ":" ;
10+ const idSeparator = ";" ;
11+
912module . exports = function ( jsonapi , data , opts ) {
1013 var alreadyIncluded = [ ] ;
1114
@@ -36,7 +39,7 @@ module.exports = function (jsonapi, data, opts) {
3639 if ( included ) {
3740 // To prevent circular references, check if the record type
3841 // has already been processed in this thread
39- if ( ancestry . indexOf ( included . type ) > - 1 ) {
42+ if ( ancestry . indexOf ( included . type + idSeparator ) > - 1 ) {
4043 return Promise
4144 . all ( [ extractAttributes ( included ) ] )
4245 . then ( function ( results ) {
@@ -47,7 +50,7 @@ module.exports = function (jsonapi, data, opts) {
4750 }
4851
4952 return Promise
50- . all ( [ extractAttributes ( included ) , extractRelationships ( included , ancestry + ':' + included . type + included . id ) ] )
53+ . all ( [ extractAttributes ( included ) , extractRelationships ( included , ancestry + ancestrySeparator + included . type + idSeparator + included . id ) ] )
5154 . then ( function ( results ) {
5255 var attributes = results [ 0 ] ;
5356 var relationships = results [ 1 ] ;
@@ -146,7 +149,7 @@ module.exports = function (jsonapi, data, opts) {
146149
147150 this . perform = function ( ) {
148151 return Promise
149- . all ( [ extractAttributes ( data ) , extractRelationships ( data , data . type + data . id ) ] )
152+ . all ( [ extractAttributes ( data ) , extractRelationships ( data , data . type + ancestrySeparator + data . id ) ] )
150153 . then ( function ( results ) {
151154 var attributes = results [ 0 ] ;
152155 var relationships = results [ 1 ] ;
0 commit comments