spooder 6.1.94 → 6.2.0
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/bun.lock +1 -1
- package/package.json +1 -1
- package/src/api.ts +12 -5
package/bun.lock
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"packages": {
|
|
13
13
|
"@types/bun": ["@types/bun@1.3.5", "", { "dependencies": { "bun-types": "1.3.5" } }, "sha512-RnygCqNrd3srIPEWBd5LFeUYG7plCoH2Yw9WaZGyNmdTEei+gWaHqydbaIRkIkcbXwhBT94q78QljxN0Sk838w=="],
|
|
14
14
|
|
|
15
|
-
"@types/node": ["@types/node@25.0.
|
|
15
|
+
"@types/node": ["@types/node@25.0.7", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-C/er7DlIZgRJO7WtTdYovjIFzGsz0I95UlMyR9anTb4aCpBSRWe5Jc1/RvLKUfzmOxHPGjSE5+63HgLtndxU4w=="],
|
|
16
16
|
|
|
17
17
|
"bun-types": ["bun-types@1.3.5", "", { "dependencies": { "@types/node": "*" } }, "sha512-inmAYe2PFLs0SUbFOWSVD24sg1jFlMPxOjOSSCYqUgn4Hsc3rDc7dFvfVYjFPNHtov6kgUeulV4SxbuIV/stPw=="],
|
|
18
18
|
|
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -978,13 +978,16 @@ export async function parse_template(template: string, replacements: Replacement
|
|
|
978
978
|
const if_regex = /<t-if\s+test="([^"]+)"\s*>(.*?)<\/t-if>/gs;
|
|
979
979
|
result = await replace_async(result, if_regex, async (match, condition_key, if_content) => {
|
|
980
980
|
const condition_value = is_replacer_fn ? await replacements(condition_key) : replacements[condition_key];
|
|
981
|
-
|
|
982
|
-
|
|
981
|
+
const key_exists = is_replacer_fn || (condition_key in replacements);
|
|
982
|
+
|
|
983
|
+
// preserve block for later pass if key doesn't exist and drop_missing is false
|
|
984
|
+
if (!key_exists && !drop_missing)
|
|
983
985
|
return match;
|
|
984
|
-
|
|
986
|
+
|
|
987
|
+
// render content if condition is truthy, otherwise remove block
|
|
985
988
|
if (condition_value)
|
|
986
989
|
return await parse_template(if_content, replacements, drop_missing);
|
|
987
|
-
|
|
990
|
+
|
|
988
991
|
return '';
|
|
989
992
|
});
|
|
990
993
|
|
|
@@ -1381,7 +1384,7 @@ type ErrorHandler = (err: Error, req: Request, url: URL) => Resolvable<Response>
|
|
|
1381
1384
|
type DefaultHandler = (req: Request, status_code: number) => HandlerReturnType;
|
|
1382
1385
|
type StatusCodeHandler = (req: Request) => HandlerReturnType;
|
|
1383
1386
|
|
|
1384
|
-
type JSONRequestHandler = (req: Request, url: URL, json: JsonObject) => HandlerReturnType;
|
|
1387
|
+
type JSONRequestHandler = (req: Request, url: URL, json: JsonObject | null) => HandlerReturnType;
|
|
1385
1388
|
|
|
1386
1389
|
export type ServerSentEventClient = {
|
|
1387
1390
|
message: (message: string) => void;
|
|
@@ -1865,6 +1868,10 @@ export function http_serve(port: number, hostname?: string) {
|
|
|
1865
1868
|
}
|
|
1866
1869
|
|
|
1867
1870
|
try {
|
|
1871
|
+
// GET/HEAD requests don't have bodies, skip validation
|
|
1872
|
+
if (req.method === 'GET' || req.method === 'HEAD')
|
|
1873
|
+
return handler(req, url, null);
|
|
1874
|
+
|
|
1868
1875
|
if (req.headers.get('Content-Type') !== 'application/json')
|
|
1869
1876
|
return 400; // Bad Request
|
|
1870
1877
|
|