@server/next 0.40.1 → 0.40.3
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/index.js +13 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -869,6 +869,12 @@ var Reply = class {
|
|
|
869
869
|
return new Response(null, { status: status2, headers: headers2 });
|
|
870
870
|
}
|
|
871
871
|
if (body === null) body = "";
|
|
872
|
+
if (typeof body === "function") body = body();
|
|
873
|
+
if (typeof body?.then === "function") {
|
|
874
|
+
throw new Error(
|
|
875
|
+
"send() received a promise, likely an async component. Await it first, or return it from the route, which resolves it for you."
|
|
876
|
+
);
|
|
877
|
+
}
|
|
872
878
|
if (typeof body === "string") {
|
|
873
879
|
if (!headers2.get("content-type")) {
|
|
874
880
|
headers2.set("content-type", isHtml(body) ? mimes_default.html : mimes_default.text);
|
|
@@ -3152,8 +3158,14 @@ function ServerTest(app) {
|
|
|
3152
3158
|
options.headers["content-type"] = "application/json";
|
|
3153
3159
|
options.body = JSON.stringify(options.body);
|
|
3154
3160
|
}
|
|
3161
|
+
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(path) && !/^https?:\/\//i.test(path)) {
|
|
3162
|
+
throw new Error(
|
|
3163
|
+
`Only http(s) URLs can be tested, received "${path}". Pass a path, or the full URL of the host the request should hit.`
|
|
3164
|
+
);
|
|
3165
|
+
}
|
|
3166
|
+
const url = /^https?:\/\//i.test(path) ? path : `http://localhost:${port}${path}`;
|
|
3155
3167
|
return await app.fetch(
|
|
3156
|
-
new Request(
|
|
3168
|
+
new Request(url, {
|
|
3157
3169
|
method,
|
|
3158
3170
|
...options
|
|
3159
3171
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@server/next",
|
|
3
|
-
"version": "0.40.
|
|
3
|
+
"version": "0.40.3",
|
|
4
4
|
"description": "A fully-fledged web server with routing, file uploads, sessions, static files, schema validation, websockets, testing, etc.",
|
|
5
5
|
"homepage": "https://server-js.com/",
|
|
6
6
|
"repository": "github:franciscop/server-next",
|