Last active
February 18, 2017 00:03
-
-
Save guizmaii/11294879 to your computer and use it in GitHub Desktop.
Helper object that help to parse the "Link" header of the Github API v3, in Scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object GithubHelper { | |
/** | |
* Parse the Github Link HTTP header used for pagination | |
* | |
* http://developer.github.com/v3/#pagination | |
* | |
* Original code found here : https://gist.github.com/niallo/3109252 | |
* | |
* @param linkHeader | |
* @return | |
*/ | |
private def parseLinkHeader(linkHeader: String): Map[String, String] = { | |
linkHeader.split(',') map { part => | |
val section = part.split(';') | |
val url = section(0).replace("<", "").replace(">", "") | |
val name = section(1).replace(" rel=\"", "").replace("\"", "") | |
(name, url) | |
}.toMap | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated to a more functional way