diff --git a/addon/adapters/github.js b/addon/adapters/github.js index 7e25aee..6ff843e 100644 --- a/addon/adapters/github.js +++ b/addon/adapters/github.js @@ -34,7 +34,7 @@ export default RESTAdapter.extend({ // } // handleResponse(status, headers, payload, requestData) { - const linkHeader = headers.Link; + const linkHeader = headers.link || headers.Link; const result = this._super(status, headers, payload, requestData); if (isNone(linkHeader)) { return result; diff --git a/tests/unit/adapters/github-test.js b/tests/unit/adapters/github-test.js index 805e0ee..3729182 100644 --- a/tests/unit/adapters/github-test.js +++ b/tests/unit/adapters/github-test.js @@ -57,6 +57,25 @@ test('it extracts links from the Link header', function(assert) { }); }); +test('it extracts links from the link header', function(assert) { + let adapter = this.subject(); + let first = '; rel="first"'; + let next = '; rel="next"'; + let prev = '; rel="prev"'; + let last = '; rel="last"'; + + let headers = { + link: [first, next, prev, last].join(', ') + }; + + assert.deepEqual(adapter.handleResponse(200, headers, {}, null).links, { + first: 'https://api.github.com/resouce?page=1&per_page=5', + next: 'https://api.github.com/resouce?page=3&per_page=5', + prev: 'https://api.github.com/resouce?page=1&per_page=5', + last: 'https://api.github.com/resouce?page=4&per_page=5' + }); +}); + test('it handles a missing Link header', function(assert) { let adapter = this.subject(); let headers = {};