issue #2965 - modify getRequestBaseUri logic #2966
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, we looked for the last instance of
/[resourceType]
in the path and assumed that was the first thing after the baseUrl. However, if a resourceId happened to match the resource type, this proved erroneous.The updated logic looks for the first instance of
/[resourceType]/
in the path instead.If that doesn't exist, then we fall back to the old approach of using the last index of
/[resourceType]
(and because we now know there was no/[resourceType]/
segment before this, this approach should now be safe).This updated logic could break if someone insisted on using a baseUrl that includes a path segment that matches
/[resourceType]/
(e.g. https://example.com/my/Patient/api/ ) but I think that is an acceptable risk because that would be very dumb to do. We could even add that guidance to the docs if we feel its needed.Signed-off-by: Lee Surprenant lmsurpre@us.ibm.com