Skip to content

Commit

Permalink
Code review feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
tjprescott committed Mar 28, 2024
1 parent ec19cc7 commit a845ba4
Showing 1 changed file with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
import { Operation, createRule } from "@typespec/compiler";
import { ModelProperty, Operation, createRule } from "@typespec/compiler";
import { getHttpOperation } from "@typespec/http";

function getCaseInsensitiveHeader(
headers: Record<string, ModelProperty> | undefined,
key: string
): string | undefined {
if (!headers) {
return undefined;
}
for (const header of Object.keys(headers)) {
if (header.toLowerCase() === key.toLowerCase()) {
return header;
}
}
return undefined;
}

/**
* Ensure that LRO 202 responses have a Location Header.
*/
Expand All @@ -22,7 +37,7 @@ export const lroLocationHeaderRule = createRule({
continue;
}
for (const resp of response.responses) {
if (resp.headers?.["Location"] === undefined) {
if (getCaseInsensitiveHeader(resp.headers, "Location") === undefined) {
context.reportDiagnostic({
target: op,
});
Expand Down

0 comments on commit a845ba4

Please sign in to comment.