Fix - POST Bundle With ifNoneExist Clause Incorrectly Rejected With Invalid Match URL ERROR (#4588)

* Add a failing Unit Test and a changelog.

* Fixed the regex to accept the dash character.
This commit is contained in:
Kevin Dougan SmileCDR 2023-02-24 14:05:07 -05:00 committed by GitHub
parent 3554e9cf91
commit b25f364369
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

View File

@ -0,0 +1,4 @@
---
type: fix
issue: 4580
title: "Fix the BaseTransactionProcessor.UNQUALIFIED_MATCH_URL_START REGEX so that it correctly matches patterns that contain dashes in them."

View File

@ -27,6 +27,7 @@ import org.hl7.fhir.r4.model.IdType;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class BaseTransactionProcessorTest {
@ -102,4 +103,11 @@ public class BaseTransactionProcessorTest {
assertEquals(input, outcome);
}
@Test
void testUnqualifiedMatchUrlStart_RegexPatternMatches() {
String matchUrl = "patient-first-identifier=MRN%7C123456789";
boolean matchResult = BaseTransactionProcessor.UNQUALIFIED_MATCH_URL_START.matcher(matchUrl).find();
assertTrue(matchResult, "Failed to find a Regex match using Url '" + matchUrl + "'");
}
}

View File

@ -137,7 +137,7 @@ public abstract class BaseTransactionProcessor {
public static final String URN_PREFIX = "urn:";
public static final String URN_PREFIX_ESCAPED = UrlUtil.escapeUrlParam(URN_PREFIX);
public static final Pattern UNQUALIFIED_MATCH_URL_START = Pattern.compile("^[a-zA-Z0-9_]+=");
public static final Pattern UNQUALIFIED_MATCH_URL_START = Pattern.compile("^[a-zA-Z0-9_-]+=");
public static final Pattern INVALID_PLACEHOLDER_PATTERN = Pattern.compile("[a-zA-Z]+:.*");
private static final Logger ourLog = LoggerFactory.getLogger(BaseTransactionProcessor.class);
@Autowired