refactor res.links()

Esse commit está contido em:
TJ Holowaychuk
2013-09-07 15:26:12 -07:00
commit 8e2f538983
2 arquivos alterados com 4 adições e 4 exclusões
+3 -3
Ver Arquivo
@@ -55,9 +55,9 @@ res.status = function(code){
*/
res.links = function(links){
var linkField = typeof this.get('Link') === 'undefined' ?
'' : this.get('Link') + ', ';
return this.set('Link', linkField + Object.keys(links).map(function(rel){
var link = this.get('Link') || '';
if (link) link += ', ';
return this.set('Link', link + Object.keys(links).map(function(rel){
return '<' + links[rel] + '>; rel="' + rel + '"';
}).join(', '));
};
+1 -1
Ver Arquivo
@@ -26,11 +26,11 @@ describe('res', function(){
next: 'http://api.example.com/users?page=2',
last: 'http://api.example.com/users?page=5'
});
res.links({
prev: 'http://api.example.com/users?page=1',
});
console.log(res.get('link'));
res.get('link')
.should.equal(
'<http://api.example.com/users?page=2>; rel="next", '