Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

h3

Package Overview
Dependencies
Maintainers
1
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

h3 - npm Package Compare versions

Comparing version 0.2.4 to 0.2.5

2

CHANGELOG.md

@@ -5,2 +5,4 @@ # Changelog

### [0.2.5](https://github.com/nuxt-contrib/h3/compare/v0.2.4...v0.2.5) (2021-02-19)
### [0.2.4](https://github.com/nuxt-contrib/h3/compare/v0.2.3...v0.2.4) (2021-01-22)

@@ -7,0 +9,0 @@

73

dist/index.js

@@ -5,2 +5,3 @@ 'use strict';

const PLUS_RE = /\+/g;
function decode(text = "") {

@@ -13,2 +14,5 @@ try {

}
function decodeQueryValue(text) {
return decode(text.replace(PLUS_RE, " "));
}

@@ -26,3 +30,3 @@ function parseQuery(paramsStr = "") {

const key = decode(s[1]);
const value = decode(s[2] || "");
const value = decodeQueryValue(s[2] || "");
if (obj[key]) {

@@ -44,5 +48,18 @@ if (Array.isArray(obj[key])) {

}
function hasTrailingSlash(input = "") {
return input.endsWith("/");
}
function withoutTrailingSlash(input = "") {
return input.endsWith("/") ? input.slice(0, -1) : input;
return (hasTrailingSlash(input) ? input.slice(0, -1) : input) || "/";
}
function withoutBase(input, base) {
if (!base || base === "/") {
return input;
}
const _base = withoutTrailingSlash(base);
if (input.startsWith(_base)) {
return input.substr(_base.length) || "/";
}
return input;
}
function getQuery(input) {

@@ -117,6 +134,3 @@ return parseQuery(parseURL(input).search);

req.originalUrl = req.originalUrl || req.url || "/";
req.url = req.url || "";
if (req.url.startsWith(base)) {
req.url = req.url.substr(base.length) || "/";
}
req.url = withoutBase(req.url || "/", base);
return handle(req, res);

@@ -126,51 +140,37 @@ };

// https://github.com/fastify/secure-json-parse
// https://github.com/hapijs/bourne
var suspectProtoRx = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
var suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
var JsonSigRx = /^["{[]|^-?[0-9][0-9.]{0,14}$/;
const suspectProtoRx = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
const suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
const JsonSigRx = /^["{[]|^-?[0-9][0-9.]{0,14}$/;
function jsonParseTransform(key, value) {
if (key === '__proto__' || key === 'constructor') {
if (key === "__proto__" || key === "constructor") {
return;
}
return value;
}
function destr(val) {
if (typeof val !== 'string') {
if (typeof val !== "string") {
return val;
}
var _lval = val.toLowerCase();
if (_lval === 'true') {
const _lval = val.toLowerCase();
if (_lval === "true") {
return true;
}
if (_lval === 'false') {
if (_lval === "false") {
return false;
}
if (_lval === 'null') {
if (_lval === "null") {
return null;
}
if (_lval === 'nan') {
if (_lval === "nan") {
return NaN;
}
if (_lval === 'infinity') {
if (_lval === "infinity") {
return Infinity;
}
if (_lval === 'undefined') {
return undefined;
if (_lval === "undefined") {
return void 0;
}
if (!JsonSigRx.test(val)) {
return val;
}
try {

@@ -180,3 +180,2 @@ if (suspectProtoRx.test(val) || suspectConstructorRx.test(val)) {

}
return JSON.parse(val);

@@ -188,4 +187,2 @@ } catch (_e) {

var dist = destr;
const RawBodySymbol = Symbol("h3RawBody");

@@ -214,3 +211,3 @@ const ParsedBodySymbol = Symbol("h3RawBody");

const body = await useRawBody(req);
const json = dist(body);
const json = destr(body);
req[ParsedBodySymbol] = json;

@@ -554,3 +551,3 @@ return json;

for (const layer of stack) {
if (layer.route.length) {
if (layer.route.length > 1) {
if (!reqUrl.startsWith(layer.route)) {

@@ -557,0 +554,0 @@ continue;

{
"name": "h3",
"version": "0.2.4",
"version": "0.2.5",
"description": "Tiny JavaScript Server",

@@ -5,0 +5,0 @@ "repository": "nuxt-contrib/h3",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc