I've seen that duplication myself and consider it a bug in Canvas code, but Peter is right about it shouldn't be affecting things. He's also right that you want the one before the "rel". It's a comma separated list of links and the semicolon separates the link from the relationship.
You can split on the comma and iterate through array. This is what I do with my PHP code, but it's not absolutely necessary to split it. Here's a fairly lazy check for a "next" link in PHP. It assumes that the link headers are in $link. If it succeeds, then $matches[1] will contain the URL.
preg_match( '/<(.*?)>; rel="next"/', $link, $matches )
There's a lengthy discussion on the Canvas Developer's group about Handling Pagination that has contributions from several people and code examples in multiple languages.