fix!: do not return undefined headers (Node 16 update)#33
Merged
Manuel Spagnolo (shikaan) merged 10 commits intomasterfrom Aug 23, 2021
Merged
fix!: do not return undefined headers (Node 16 update)#33Manuel Spagnolo (shikaan) merged 10 commits intomasterfrom
Manuel Spagnolo (shikaan) merged 10 commits intomasterfrom
Conversation
BREAKING CHANGE
BREAKING CHANGE
Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7. - [Release notes](https://github.com/jbgutierrez/path-parse/releases) - [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7) --- updated-dependencies: - dependency-name: path-parse dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
BREAKING CHANGE
b12b5af to
f9d2705
Compare
| rawTimestamp?: Timestamp, | ||
| rawContext?: any | ||
| ) { | ||
| const maybeDefaultTimestamp = rawTimestamp ?? Date.now() |
Contributor
There was a problem hiding this comment.
nit: I don't really like that variable name. It doesn't really say what it is actually storing. Also: Why not using the fallback date in the function's signature as we did in the old impementation?
| { ...headers, ...(contextHeaders as Record<string, string>) }, | ||
| timestamp | ||
| ) | ||
| const contextHeaders = rawContext ? normalizeContextHeaders(rawContext) : undefined |
Contributor
There was a problem hiding this comment.
You can simplify the next few lines by setting contextHeaders to {} if rawContext is not defined.
That way you can remove the condition in line 106-108 and remove the nullish coalescing (??) from line 114.
This would make things easier to read imo.
const contextHeaders = rawContext ? normalizeContextHeaders(rawContext) : {}
const { sortedHeaders, signedHeaders } = getSortedAndSignedHeaders(
{ ...headers, ...contextHeaders },
timestamp
)
return {
[ContentfulHeader.Signature]: hash({ method, headers: sortedHeaders, path, body }, secret),
[ContentfulHeader.SignedHeaders]: signedHeaders,
[ContentfulHeader.Timestamp]: timestamp.toString(),
...contextHeaders,
}
Kado (kdamball)
approved these changes
Aug 20, 2021
Contributor
Kado (kdamball)
left a comment
There was a problem hiding this comment.
LGTM beside the point Andi made
Manuel Spagnolo (shikaan)
added a commit
that referenced
this pull request
Aug 23, 2021
* fix!: do not return undefined headers, cleanup * test!: cover no context case + cleanup BREAKING CHANGE: this changes typings
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.
Node 16 seems to be much less tolerant when it comes to
undefinedheaders (previous versions were ignoring headers, nwer versions are complaining about the headers type not being astring).