@remix-run/method-override-middleware 0.1.9 → 0.1.11

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.
@@ -1 +1 @@
1
- {"version":3,"file":"method-override.d.ts","sourceRoot":"","sources":["../../src/lib/method-override.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,yBAAyB,CAAA;AAEzE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,UAAU,CAe1E"}
1
+ {"version":3,"file":"method-override.d.ts","sourceRoot":"","sources":["../../src/lib/method-override.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEzD;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,UAAU,CAgB1E"}
@@ -11,14 +11,14 @@ import { isRequestMethod } from '@remix-run/fetch-router';
11
11
  */
12
12
  export function methodOverride(options) {
13
13
  let fieldName = options?.fieldName ?? '_method';
14
- return (context) => {
14
+ return (context, next) => {
15
15
  let method = context.get(FormData)?.get(fieldName);
16
- if (typeof method !== 'string') {
17
- return;
18
- }
19
- let requestMethod = method.toUpperCase();
20
- if (isRequestMethod(requestMethod)) {
21
- context.method = requestMethod;
16
+ if (typeof method === 'string') {
17
+ let requestMethod = method.toUpperCase();
18
+ if (isRequestMethod(requestMethod)) {
19
+ context.method = requestMethod;
20
+ }
22
21
  }
22
+ return next();
23
23
  };
24
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remix-run/method-override-middleware",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "Middleware for overriding HTTP request methods from form data",
5
5
  "author": "Michael Jackson <mjijackson@gmail.com>",
6
6
  "license": "MIT",
@@ -28,13 +28,13 @@
28
28
  "devDependencies": {
29
29
  "@types/node": "^24.6.0",
30
30
  "@typescript/native-preview": "7.0.0-dev.20251125.1",
31
- "@remix-run/assert": "0.2.1",
32
- "@remix-run/test": "0.4.1",
33
- "@remix-run/fetch-router": "0.19.1",
34
- "@remix-run/form-data-middleware": "0.3.1"
31
+ "@remix-run/assert": "0.3.0",
32
+ "@remix-run/fetch-router": "0.20.0",
33
+ "@remix-run/form-data-middleware": "0.3.3",
34
+ "@remix-run/test": "0.5.0"
35
35
  },
36
36
  "dependencies": {
37
- "@remix-run/fetch-router": "^0.19.1"
37
+ "@remix-run/fetch-router": "^0.20.0"
38
38
  },
39
39
  "keywords": [
40
40
  "fetch",
@@ -1,5 +1,5 @@
1
1
  import { isRequestMethod } from '@remix-run/fetch-router'
2
- import type { Middleware, RequestContext } from '@remix-run/fetch-router'
2
+ import type { Middleware } from '@remix-run/fetch-router'
3
3
 
4
4
  /**
5
5
  * Options for the {@link methodOverride} middleware.
@@ -26,16 +26,17 @@ export interface MethodOverrideOptions {
26
26
  export function methodOverride(options?: MethodOverrideOptions): Middleware {
27
27
  let fieldName = options?.fieldName ?? '_method'
28
28
 
29
- return (context: RequestContext) => {
29
+ return (context, next) => {
30
30
  let method = context.get(FormData)?.get(fieldName)
31
- if (typeof method !== 'string') {
32
- return
33
- }
34
31
 
35
- let requestMethod = method.toUpperCase()
32
+ if (typeof method === 'string') {
33
+ let requestMethod = method.toUpperCase()
36
34
 
37
- if (isRequestMethod(requestMethod)) {
38
- context.method = requestMethod
35
+ if (isRequestMethod(requestMethod)) {
36
+ context.method = requestMethod
37
+ }
39
38
  }
39
+
40
+ return next()
40
41
  }
41
42
  }