Omit empty First value and only set on New with items>0
Supports fixing writefreely/writefreely#1698
This commit is contained in:
@@ -30,7 +30,7 @@ type (
|
|||||||
type OrderedCollection struct {
|
type OrderedCollection struct {
|
||||||
BaseObject
|
BaseObject
|
||||||
TotalItems int `json:"totalItems"`
|
TotalItems int `json:"totalItems"`
|
||||||
First string `json:"first"`
|
First string `json:"first,omitempty"`
|
||||||
Last string `json:"last,omitempty"`
|
Last string `json:"last,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,9 +43,13 @@ func NewOrderedCollection(accountRoot, collType string, items int) *OrderedColle
|
|||||||
ID: accountRoot + "/" + collType,
|
ID: accountRoot + "/" + collType,
|
||||||
Type: "OrderedCollection",
|
Type: "OrderedCollection",
|
||||||
},
|
},
|
||||||
First: accountRoot + "/" + collType + "?page=1",
|
|
||||||
TotalItems: items,
|
TotalItems: items,
|
||||||
}
|
}
|
||||||
|
if items > 0 {
|
||||||
|
// Next page should only be indicated if there are potentially items on it. NOTE: with no knowledge of items-
|
||||||
|
// per-page, this still may need to be altered by the func caller.
|
||||||
|
oc.First = accountRoot + "/" + collType + "?page=1"
|
||||||
|
}
|
||||||
return &oc
|
return &oc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user