MCPcopy Create free account
hub / github.com/honojs/node-server / normalizeIncomingMethod

Function normalizeIncomingMethod

src/request.ts:169–197  ·  view source on GitHub ↗
(method: unknown)

Source from the content-addressed store, hash-verified

167const methodTokenRegExp = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/
168
169const normalizeIncomingMethod = (method: unknown): string => {
170 if (typeof method !== 'string' || method.length === 0) {
171 return 'GET'
172 }
173
174 // fast path for already-uppercase common methods from Node.js.
175 switch (method) {
176 case 'DELETE':
177 case 'GET':
178 case 'HEAD':
179 case 'OPTIONS':
180 case 'POST':
181 case 'PUT':
182 return method
183 }
184
185 const upper = method.toUpperCase()
186 switch (upper) {
187 case 'DELETE':
188 case 'GET':
189 case 'HEAD':
190 case 'OPTIONS':
191 case 'POST':
192 case 'PUT':
193 return upper
194 default:
195 return method
196 }
197}
198
199const validateDirectReadMethod = (method: string): TypeError | undefined => {
200 if (!methodTokenRegExp.test(method)) {

Callers 1

newRequestFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…