Skip to content

Commit

Permalink
handle Node 18 more gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed Jan 16, 2025
1 parent f5b1aa1 commit 594b25f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion shared/api-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ export async function respondWithDataTable(data: URLSearchParams | FormData) {
const headerCellStyle = `${cellStyle} border-bottom-width: 2px;`

async function stringifyValue(value: string | File) {
if (value instanceof File) {
// this would be value instanceof File except the global File was not added until Node 20.
// feel free to update this when we drop Node 18 support after April 2025.
if (
typeof value === 'object' &&
'size' in value &&
'arrayBuffer' in value &&
'type' in value &&
'name' in value
) {
if (value.size > MAX_FILE_SIZE) {
throw new Response(`File larger than ${MAX_FILE_SIZE} bytes`, {
status: 400,
Expand Down

0 comments on commit 594b25f

Please sign in to comment.