commit d03fda89b28811008c78c53de9c2bc919e76009e parent 69cc8359da2e929fd1bdc8113bc82141d0658291 Author: MS <ms@taler.net> Date: Mon, 14 Dec 2020 17:44:36 +0100 allowing subjects broken into multiple lines Diffstat:
| M | nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt | | | 2 | +- |
| M | nexus/src/test/kotlin/SubjectNormalization.kt | | | 2 | ++ |
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt @@ -196,7 +196,7 @@ fun customConverter(body: Any): String { */ fun extractReservePubFromSubject(rawSubject: String): String? { val re = "\\b[a-z0-9A-Z]{52}\\b".toRegex() - val result = re.find(rawSubject) ?: return null + val result = re.find(rawSubject.replace("[\n]+".toRegex(), "")) ?: return null return result.value.toUpperCase() } diff --git a/nexus/src/test/kotlin/SubjectNormalization.kt b/nexus/src/test/kotlin/SubjectNormalization.kt @@ -9,5 +9,7 @@ class SubjectNormalization { val mereValue = "1ENVZ6EYGB6Z509KRJ6E59GK1EQXZF8XXNY9SN33C2KDGSHV9KA0" assert(mereValue == extractReservePubFromSubject(mereValue)) assert(mereValue == extractReservePubFromSubject("noise before ${mereValue} noise after")) + val mereValueNewLines = "\t1ENVZ6EYGB6Z\n\n\n509KRJ6E59GK1EQXZF8XXNY9\nSN33C2KDGSHV9KA0" + assert(mereValue == extractReservePubFromSubject(mereValueNewLines)) } } \ No newline at end of file