test NPE in markdown processing

This commit is contained in:
Grahame Grieve 2023-01-10 11:34:41 +11:00
parent 6725563600
commit 90f7214195
2 changed files with 30 additions and 4 deletions

View File

@ -1703,24 +1703,24 @@ public class ProfileUtilities extends TranslatingUtilities {
private static boolean isLikelySourceURLReference(String url, List<String> resourceNames, Set<String> baseFilenames, Set<String> localFilenames) {
if (resourceNames != null) {
for (String n : resourceNames) {
if (url.startsWith(n.toLowerCase()+".html")) {
if (n != null && url.startsWith(n.toLowerCase()+".html")) {
return true;
}
if (url.startsWith(n.toLowerCase()+"-definitions.html")) {
if (n != null && url.startsWith(n.toLowerCase()+"-definitions.html")) {
return true;
}
}
}
if (localFilenames != null) {
for (String n : localFilenames) {
if (url.startsWith(n.toLowerCase())) {
if (n != null && url.startsWith(n.toLowerCase())) {
return false;
}
}
}
if (baseFilenames != null) {
for (String n : baseFilenames) {
if (url.startsWith(n.toLowerCase())) {
if (n != null && url.startsWith(n.toLowerCase())) {
return true;
}
}

View File

@ -0,0 +1,26 @@
package org.hl7.fhir.r5.utils;
import static org.junit.jupiter.api.Assertions.*;
import java.util.List;
import java.util.Set;
import org.hl7.fhir.r5.conformance.profile.ProfileUtilities;
import org.hl7.fhir.r5.context.ContextUtilities;
import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.test.utils.TestingUtilities;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
class MarkdownTests {
@Test
void test() {
IWorkerContext ctxt = TestingUtilities.getSharedWorkerContext();
ContextUtilities cu = new ContextUtilities(ctxt);
ProfileUtilities pu = new ProfileUtilities(ctxt, null, cu);
String s = pu.processRelativeUrls("UDI may identify an unique instance of a device, or it may only identify the type of the device. See [UDI mappings](device-mappings.html#udi) for a complete mapping of UDI parts to Device.",
"http://hl7.org/fhir", "", cu.getTypeNames(), null, null, true);
Assertions.assertNotNull(s);
}
}