Fix missing default Accept header when options is an empty object#178
Open
soyuka wants to merge 1 commit into
Open
Fix missing default Accept header when options is an empty object#178soyuka wants to merge 1 commit into
soyuka wants to merge 1 commit into
Conversation
setHeaders() short-circuited on falsy options.headers, returning a
plain {} instead of building Headers with the Accept default. This
broke @api-platform/admin's schemaAnalyzer, which always calls
getParameters() with an explicit {} (see #177).
Removed the early return so the function always falls through to the
Headers/Accept logic, and swapped the headers derivation to avoid
mutating the caller's options object as a side effect.
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
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
Alternative fix for #177.
setHeaders()short-circuited on falsyoptions.headers, returning a plain{}instead of buildingHeaderswith theAcceptdefault. This breaks@api-platform/admin'sschemaAnalyzer.resolveSchemaParameters(), which always callsgetParameters()with an explicit{}.#177's fix (
options.headers = {}instead ofreturn) works, but mutates the caller-suppliedoptionsobject as a side effect before falling through. This PR removes the early-return branch entirely and derivesheaderswithout mutating the input:optionsobject.Acceptheader is sent whenoptionsis{}.fetchJsonLddoes not mutate the passedoptionsobject.Test plan
pnpm typecheckpnpm format:checkpnpm test src/hydra/fetchJsonLd.test.ts(blocked locally by unrelated stray Yarn PnP files in this checkout; relying on CI)