Repository: honojs/hono
File: src/utils/body.ts (TypeScript)

Code before:
    return convertFormDataToBodyData<T>(formData, options)
  }

  return {} as T
}

function convertFormDataToBodyData<T extends BodyData = BodyData>(
  formData: FormData,
  options: ParseBodyOptions
): T {
  const form: BodyData = Object.create(null)

  formData.forEach((value, key) => {
    const shouldParseAllValues = options.all || key.endsWith('[]')

    if (!shouldParseAllValues) {
      handleNestedValues(form, key, value, options.dot)
    } else {
      handleParsingAllValues(form, key, value, options.dot)
    }
  })

  return form as T
}

const handleParsingAllValues = (
  form: BodyData,
  key: string,
  value: FormDataEntryValue,
  dot?: boolean
): void => {
  if (dot && key.includes('.')) {
    handleNestedValues(form, key, value, dot, true)
  } else {
    if (form[key] !== undefined) {
      if (Array.isArray(form[key])) {
        ;(form[key] as (string | File)[]).push(value)
      } else {
        form[key] = [form[key] as string | File, value]
      }
    } else {
      form[key] = value
    }
  }
}

const handleNestedValues = (
  form: BodyData,
  key: string,
  value: FormDataEntryValue,
  dot?: boolean,

Review comment (suggestion):
Removed the dot logic from here. This makes it similar to the original code too

```ts
const handleParsingAllValues = (
  form: BodyData,
  key: string,
  value: FormDataEntryValue,
): void => {
  const formKey = form[key]

  if (formKey && Array.isArray(formKey)) {
    ;(form[key] as (string | File)[]).push(value)
  } else if (formKey) {
    form[key] = [formKey as (string | File), value]
  } else {
    form[key] = value
  }
}
```

Code after:

/**
 * Parses form data from a request.
 *
 * @template T - The type of the parsed body data.
 * @param {HonoRequest | Request} request - The request object containing form data.
 * @param {ParseBodyOptions} options - Options for parsing the form data.
 * @returns {Promise<T>} The parsed body data.
 */
async function parseFormData<T extends BodyData = BodyData>(
  request: HonoRequest | Request,
  options: ParseBodyOptions
): Promise<T> {
  const formData = await (request as Request).formData()

  if (formData) {
    return convertFormDataToBodyData<T>(formData, options)
  }

  return {} as T
}

/**
 * Converts form data to body data based on the provided options.
 *
 * @template T - The type of the parsed body data.
 * @param {FormData} formData - The form data to convert.
 * @param {ParseBodyOptions} options - Options for parsing the form data.
 * @returns {T} The converted body data.
 */
function convertFormDataToBodyData<T extends BodyData = BodyData>(
  formData: FormData,
  options: ParseBodyOptions
): T {
  const form: BodyData = Object.create(null)

  formData.forEach((value, key) => {
    const shouldParseAllValues = options.all || key.endsWith('[]')

    if (shouldParseAllValues) {
      handleParsingAllValues(form, key, value)
    } else {
      form[key] = value
    }
  })

  if (options.dot) {
    const nestedForm: BodyData = Object.create(null)

    Object.entries(form).forEach(([key, value]) => {
      const shouldParseDotValues = key.includes('.')