Conversation
bhelx
commented
Jan 29, 2025
|
|
||
| const { headers, header, url: rawUrl, method: m } = req.json(); | ||
| const method = m ?? 'GET'; | ||
| const method = m?.toUpperCase() ?? 'GET'; |
Contributor
Author
There was a problem hiding this comment.
i noticed there are explicit conditional checks for uppercase below. is there somewhere else this could be getting set?
Contributor
There was a problem hiding this comment.
Nope – I think this code used to assume that the pdk will always call with uppercased HTTP verbs.
chrisdickinson
approved these changes
Jan 29, 2025
|
|
||
| const { headers, header, url: rawUrl, method: m } = req.json(); | ||
| const method = m ?? 'GET'; | ||
| const method = m?.toUpperCase() ?? 'GET'; |
Contributor
There was a problem hiding this comment.
Huh, TIL ?. earlier in the chain cascades to the ()! I would've thought m?.toUpperCase?.() would be required.
Contributor
Author
There was a problem hiding this comment.
i think it works for methods too? at least i've been doing this in other places. the compiler didn't complain but also i think it's an any. This does seem to work though:
function z(s?: string | null) {
console.log(s?.toUpperCase() || "GET")
}
z()
Contributor
Author
There was a problem hiding this comment.
becomes:
"use strict";
function z(s) {
console.log((s === null || s === void 0 ? void 0 : s.toUpperCase()) || "GET");
}
z();
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.
Unclear exactly if this is a problem here or if this is the right spot, but had an issue where googleapis.com didn't accept a lowercase http method from the client. gonna make sure the same is in go and rust.