Browse Source

Trim space around link header values

ref #22
Yann Malet 13 years ago
committed by Will Norris
parent
commit
fefe56aa01
2 changed files with 4 additions and 4 deletions
  1. +1
    -1
      github/github.go
  2. +3
    -3
      github/github_test.go

+ 1
- 1
github/github.go View File

@ -189,7 +189,7 @@ func newResponse(r *http.Response) *Response {
func (r *Response) populatePageValues() { func (r *Response) populatePageValues() {
if links, ok := r.Response.Header["Link"]; ok && len(links) > 0 { if links, ok := r.Response.Header["Link"]; ok && len(links) > 0 {
for _, link := range strings.Split(links[0], ",") { for _, link := range strings.Split(links[0], ",") {
segments := strings.Split(link, ";")
segments := strings.Split(strings.TrimSpace(link), ";")
// link must at least have href and rel // link must at least have href and rel
if len(segments) < 2 { if len(segments) < 2 {


+ 3
- 3
github/github_test.go View File

@ -134,9 +134,9 @@ func TestResponse_populatePageValues(t *testing.T) {
r := http.Response{ r := http.Response{
Header: http.Header{ Header: http.Header{
"Link": {`<https://api.github.com/?page=1>; rel="first",` + "Link": {`<https://api.github.com/?page=1>; rel="first",` +
`<https://api.github.com/?page=2>; rel="prev",` +
`<https://api.github.com/?page=4>; rel="next",` +
`<https://api.github.com/?page=5>; rel="last"`,
` <https://api.github.com/?page=2>; rel="prev",` +
` <https://api.github.com/?page=4>; rel="next",` +
` <https://api.github.com/?page=5>; rel="last"`,
}, },
}, },
} }


Loading…
Cancel
Save