fix(sap-commerce-cloud): skip prepending apiEndpoint for absolute image URLs#10672
Open
Mihai (Mihai-Sprinceana) wants to merge 1 commit intocontentful:masterfrom
Open
fix(sap-commerce-cloud): skip prepending apiEndpoint for absolute image URLs#10672Mihai (Mihai-Sprinceana) wants to merge 1 commit intocontentful:masterfrom
Mihai (Mihai-Sprinceana) wants to merge 1 commit intocontentful:masterfrom
Conversation
…ge URLs When the SAP Commerce Cloud API returns images with full absolute URLs (e.g. https://static.test.com/media/123), the transformer was blindly prepending the apiEndpoint, producing a malformed URL such as https://api.test.com/https://static.test.com/media/123. Guard both productTransformer and productDetailsTransformer so that apiEndpoint is only prepended when the imageUrl is a relative path. Fixes contentful#10235 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
Fixes #10235
productTransformerandproductDetailsTransformer, theapiEndpointwas unconditionally prepended to any non-emptyimageUrl.https://static.test.com/media/123), this produced malformed URLs likehttps://api.test.com/https://static.test.com/media/123.apiEndpointis only prepended when the image URL is a relative path (does not start withhttp://orhttps://).Changes
apps/sap-commerce-cloud/frontend/src/api/dataTransformers.ts: updated theimageUrlcondition in bothproductTransformerandproductDetailsTransformer.Test plan
/media/123) still resolve correctly by prependingapiEndpointhttps://static.test.com/media/123) are passed through unchangednpm run testinapps/sap-commerce-cloud/frontenddataTransformers.test.tsto cover both cases🤖 Generated with Claude Code