h3 0.7.20 → 0.7.21

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/dist/index.cjs CHANGED
@@ -132,8 +132,8 @@ function getRequestHeader(event, name) {
132
132
  }
133
133
  const getHeader = getRequestHeader;
134
134
 
135
- const RawBodySymbol = Symbol("h3RawBody");
136
- const ParsedBodySymbol = Symbol("h3RawBody");
135
+ const RawBodySymbol = Symbol.for("h3RawBody");
136
+ const ParsedBodySymbol = Symbol.for("h3ParsedBody");
137
137
  const PayloadMethods = ["PATCH", "POST", "PUT", "DELETE"];
138
138
  function readRawBody(event, encoding = "utf-8") {
139
139
  assertMethod(event, PayloadMethods);
@@ -227,14 +227,10 @@ function defaultContentType(event, type) {
227
227
  }
228
228
  }
229
229
  function sendRedirect(event, location, code = 302) {
230
- const encodedLoc = encodeURI(decodeURI(location));
231
230
  event.res.statusCode = code;
232
- event.res.setHeader("Location", encodedLoc);
233
- const html = `<!DOCTYPE html>
234
- <html>
235
- <head><meta http-equiv="refresh" content="0; url=${encodedLoc}"></head>
236
- <body>Redirecting to <a href=${JSON.stringify(encodedLoc)}>${encodedLoc}</a></body>
237
- </html>`;
231
+ event.res.setHeader("Location", location);
232
+ const encodedLoc = location.replace(/"/g, "%22");
233
+ const html = `<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0; url=${encodedLoc}"></head></html>`;
238
234
  return send(event, html, MIMES.html);
239
235
  }
240
236
  function getResponseHeaders(event) {
package/dist/index.mjs CHANGED
@@ -124,8 +124,8 @@ function getRequestHeader(event, name) {
124
124
  }
125
125
  const getHeader = getRequestHeader;
126
126
 
127
- const RawBodySymbol = Symbol("h3RawBody");
128
- const ParsedBodySymbol = Symbol("h3RawBody");
127
+ const RawBodySymbol = Symbol.for("h3RawBody");
128
+ const ParsedBodySymbol = Symbol.for("h3ParsedBody");
129
129
  const PayloadMethods = ["PATCH", "POST", "PUT", "DELETE"];
130
130
  function readRawBody(event, encoding = "utf-8") {
131
131
  assertMethod(event, PayloadMethods);
@@ -219,14 +219,10 @@ function defaultContentType(event, type) {
219
219
  }
220
220
  }
221
221
  function sendRedirect(event, location, code = 302) {
222
- const encodedLoc = encodeURI(decodeURI(location));
223
222
  event.res.statusCode = code;
224
- event.res.setHeader("Location", encodedLoc);
225
- const html = `<!DOCTYPE html>
226
- <html>
227
- <head><meta http-equiv="refresh" content="0; url=${encodedLoc}"></head>
228
- <body>Redirecting to <a href=${JSON.stringify(encodedLoc)}>${encodedLoc}</a></body>
229
- </html>`;
223
+ event.res.setHeader("Location", location);
224
+ const encodedLoc = location.replace(/"/g, "%22");
225
+ const html = `<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0; url=${encodedLoc}"></head></html>`;
230
226
  return send(event, html, MIMES.html);
231
227
  }
232
228
  function getResponseHeaders(event) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "h3",
3
- "version": "0.7.20",
3
+ "version": "0.7.21",
4
4
  "description": "Tiny JavaScript Server",
5
5
  "repository": "unjs/h3",
6
6
  "license": "MIT",