-
Notifications
You must be signed in to change notification settings - Fork 594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Match path maps in order of longest matching key prefix (#394) #586
Conversation
Test FAILed. |
Failed test is #493 |
Test FAILed. |
Test PASSed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM |
PLS BUILD |
Test PASSed. |
* | ||
* @group pathmatcherimpl | ||
*/ | ||
implicit def _valueMap2PathMatcher[T](valueMap: Map[String, T]): PathMatcher1[T] = | ||
if (valueMap.isEmpty) PathMatchers.nothingMatcher | ||
else valueMap.map { case (prefix, value) ⇒ _stringExtractionPair2PathMatcher((prefix, value)) }.reduceLeft(_ | _) | ||
else valueMap.toSeq.sortWith(_._1 > _._1).map(_stringExtractionPair2PathMatcher).reduceLeft(_ | _) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sortyBy(_._1)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checked that, actually would fail hm
Fixes #394 by ensuring order of the provided mappings instead of leaving it up to the undefined order provided by the map implementation.
It might be a bit overkill to include all of the test cases created by @gosubpl but I included them for completeness and to test with
ListMap
.