@hyperspan/framework 1.0.7 → 1.0.8
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/package.json +1 -1
- package/src/server.ts +2 -2
- package/src/utils.ts +7 -0
package/package.json
CHANGED
package/src/server.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HSHtml, html, isHSHtml, renderStream, renderAsync, render, _typeOf } from '@hyperspan/html';
|
|
2
2
|
import { isbot } from 'isbot';
|
|
3
3
|
import { executeMiddleware } from './middleware';
|
|
4
|
-
import { parsePath } from './utils';
|
|
4
|
+
import { parsePath, removeUndefined } from './utils';
|
|
5
5
|
import { Cookies } from './cookies';
|
|
6
6
|
|
|
7
7
|
import type { Hyperspan as HS } from './types';
|
|
@@ -51,7 +51,7 @@ export function createContext(req: Request, route?: HS.Route): HS.Context {
|
|
|
51
51
|
const headers = new Headers(req.headers);
|
|
52
52
|
const path = route?._path() || '/';
|
|
53
53
|
// @ts-ignore - Bun will put 'params' on the Request object even though it's not standardized
|
|
54
|
-
const params: HS.RouteParamsParser<path> & Record<string, string | undefined> = Object.assign({}, req?.params || {}, route?._config.params || {});
|
|
54
|
+
const params: HS.RouteParamsParser<path> & Record<string, string | undefined> = Object.assign({}, req?.params || {}, removeUndefined(route?._config.params || {}));
|
|
55
55
|
|
|
56
56
|
// Replace catch-all param with the value from the URL path
|
|
57
57
|
const catchAllParam = Object.keys(params).find(key => key.startsWith('...'));
|
package/src/utils.ts
CHANGED
|
@@ -136,4 +136,11 @@ export function formDataToJSON(formData: FormData | URLSearchParams): Record<str
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
return object;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Remove undefined values from an object
|
|
143
|
+
*/
|
|
144
|
+
export function removeUndefined(obj: Record<string, any>): Record<string, any> {
|
|
145
|
+
return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined));
|
|
139
146
|
}
|