refactor res.links()
Esse commit está contido em:
+3
-3
@@ -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
@@ -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", '
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário