unjs / h3

⚡️ Minimal H(TTP) framework built for high performance and portability

Home Page:https://h3.unjs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`isMethod` option `allowHead` should check `ecpected` to be `GET`

Barbapapazes opened this issue · comments

Environment

/

Reproduction

/

Describe the bug

I could miss understood but this line, https://github.com/unjs/h3/blob/main/src/utils/request.ts#L101, says 'If allowHead is true, it will allow HEAD requests to pass if the expected method is GET.' but in code

  if (allowHead && event.method === "HEAD") {
    return true;
  }

There is nothing about GET. Shouldn't be

  if (allowHead && event.method === "HEAD" && expect === 'GET') {
    return true;
  }

Additional context

No response

Logs

No response

You are correct, allowHead implicitly assumes users know the request-response is expected to be GET.

Adding more strict expect === 'GET' would work too but it is a behavior breaking change and also adds a limitation for other valid usecases when we expect method is HEAD or anything else.