Skip to content

Commit 5d07638

Browse files
committed
💩 Compare the normalized hostnames to support the equality of "localhost" and "127.0.0.1". This normalization be done somewhere else, probably while executing getBaseUrl().
1 parent 775935b commit 5d07638

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

onfhir-common/src/main/scala/io/onfhir/api/client/FhirGetSearchPageRequestBuilder.scala

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,20 @@ class FhirGetSearchPageRequestBuilder(onFhirClient: IOnFhirClient, link:String)
2020
extends FHIRSearchSetReturningRequestBuilder(onFhirClient,
2121
FHIRRequest(
2222
interaction = FHIR_INTERACTIONS.GET_SEARCH_PAGE,
23-
requestUri =
24-
if(link.startsWith(onFhirClient.getBaseUrl()))
23+
requestUri = {
24+
def normalizeUrl(url: String): String = url.replace("localhost", "127.0.0.1")
25+
//
26+
val normalizedBaseUrl = normalizeUrl(onFhirClient.getBaseUrl())
27+
val normalizedLink = normalizeUrl(link)
28+
if (normalizedLink.startsWith(normalizedBaseUrl))
2529
link.drop(onFhirClient.getBaseUrl().length)
26-
else if(link.head == '/' || link.head == '?')
30+
else if (link.head == '/' || link.head == '?')
2731
link
2832
else
29-
throw new IllegalArgumentException("The link for the search page should be either whole link starting with target FHIR server base url or partial link starting as path '/' or directly with query '?'")
33+
throw new IllegalArgumentException(
34+
s"The link for the search page should be either whole link starting with target FHIR server base url or partial link starting as path '/' or directly with query '?'. Link: $link"
35+
)
36+
}
3037
)) {
3138

3239

0 commit comments

Comments
 (0)