Skip to content

Commit

Permalink
#76 Fix order when extracting list of strings from Fields object
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Dec 19, 2018
1 parent 72a6e94 commit d87f867
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions app/org/elastic4play/controllers/Fields.scala
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,7 @@ class Fields(private val fields: Map[String, InputValue]) {
*/
def getStrings(name: String): Option[Seq[String]] = fields.get(name) flatMap {
case StringInputValue(ss) Some(ss)
case JsonInputValue(JsArray(js)) js.foldLeft[Option[Seq[String]]](Some(Nil)) {
case (Some(l), JsString(s)) Some(s +: l)
case _ None
}
case JsonInputValue(js: JsArray) js.asOpt[Seq[String]]
case _ None
}

Expand All @@ -113,10 +110,7 @@ class Fields(private val fields: Map[String, InputValue]) {
*/
def getStrings(name: String, separator: String): Option[Seq[String]] = fields.get(name) flatMap {
case StringInputValue(ss) Some(ss.flatMap(_.split(separator)).filterNot(_.isEmpty))
case JsonInputValue(JsArray(js)) js.foldLeft[Option[Seq[String]]](Some(Nil)) {
case (Some(l), JsString(s)) Some(s +: l)
case _ None
}
case JsonInputValue(js: JsArray) js.asOpt[Seq[String]]
case _ None
}

Expand Down

0 comments on commit d87f867

Please sign in to comment.