Skip to content

Commit

Permalink
simplification and code-golfing
Browse files Browse the repository at this point in the history
  • Loading branch information
kwhitley committed Apr 3, 2024
1 parent c94e334 commit 6e27a87
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/cors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const cors = (options: CorsOptions = {}) => {
: origin
}

const appendHeadersAndReturn = (response: Response, headers: Record<string, any>) => {
const appendHeadersAndReturn = (response: Response, headers: Record<string, any>): Response => {
for (const [key, value] of Object.entries(headers)) {
if (value) response.headers.append(key, value)
}
Expand Down Expand Up @@ -86,12 +86,6 @@ export const cors = (options: CorsOptions = {}) => {
// clone the response
// response = response.clone()

// const origin = getAccessControlOrigin(request)
// if (origin) response.headers.append('access-control-allow-origin', origin)

// for (const [key, value] of Object.entries(corsHeaders)) {
// if (value) response.headers.append(key, value)
// }
return appendHeadersAndReturn(response, {
'access-control-allow-origin': getAccessControlOrigin(request),
...corsHeaders
Expand Down

0 comments on commit 6e27a87

Please sign in to comment.