mastercontroller 1.3.26 → 1.3.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MasterRouter.js +6 -1
- package/package.json +1 -1
package/MasterRouter.js
CHANGED
|
@@ -37,7 +37,9 @@ const HTTP_METHODS = {
|
|
|
37
37
|
GET: 'get',
|
|
38
38
|
POST: 'post',
|
|
39
39
|
PUT: 'put',
|
|
40
|
+
PATCH: 'patch',
|
|
40
41
|
DELETE: 'delete',
|
|
42
|
+
HEAD: 'head',
|
|
41
43
|
OPTIONS: 'options'
|
|
42
44
|
};
|
|
43
45
|
|
|
@@ -239,7 +241,10 @@ const ROUTER_CONFIG = {
|
|
|
239
241
|
const pathObj = normalizePaths(requestObject.pathName, route.path, testParams);
|
|
240
242
|
|
|
241
243
|
// if we find the route that matches the request
|
|
242
|
-
|
|
244
|
+
// HEAD requests match GET routes per HTTP spec (RFC 9110 §9.3.2)
|
|
245
|
+
const methodMatches = route.type === requestObject.type
|
|
246
|
+
|| (requestObject.type === HTTP_METHODS.HEAD && route.type === HTTP_METHODS.GET);
|
|
247
|
+
if(pathObj.requestPath === pathObj.routePath && methodMatches){
|
|
243
248
|
// Only commit the extracted params if this route actually matches
|
|
244
249
|
requestObject.params = testParams;
|
|
245
250
|
|
package/package.json
CHANGED