Conversation
lmsurpre
commented
Nov 9, 2021
Previously, we looked for the last instnace 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]` (now that we know it should be safe to do so). This updated logic could break if someone insisted on including 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. Alternatives would be to either A. rely solely on a configured baseUrl; or B. do more processing of the URL to ensure we're stripping a path and not a hostname Signed-off-by: Lee Surprenant <lmsurpre@us.ibm.com>
/resourceType and not the lastand add a test to OriginalRequestRewriteServerTest for the exact examples used in the docs Signed-off-by: Lee Surprenant <lmsurpre@us.ibm.com>
prb112
approved these changes
Nov 10, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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