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

hono

Package Overview
Dependencies
Maintainers
1
Versions
344
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hono - npm Package Compare versions

Comparing version 4.2.2 to 4.2.3

5

dist/cjs/client/client.js

@@ -137,3 +137,6 @@ "use strict";

if (method === "ws") {
const targetUrl = opts.args[0] && opts.args[0].param ? (0, import_utils.replaceUrlParam)(url, opts.args[0].param) : url;
const targetUrl = (0, import_utils.replaceUrlProtocol)(
opts.args[0] && opts.args[0].param ? (0, import_utils.replaceUrlParam)(url, opts.args[0].param) : url,
"ws"
);
return new WebSocket(targetUrl);

@@ -140,0 +143,0 @@ }

14

dist/cjs/client/utils.js

@@ -24,3 +24,4 @@ "use strict";

removeIndexString: () => removeIndexString,
replaceUrlParam: () => replaceUrlParam
replaceUrlParam: () => replaceUrlParam,
replaceUrlProtocol: () => replaceUrlProtocol
});

@@ -41,2 +42,10 @@ module.exports = __toCommonJS(utils_exports);

};
const replaceUrlProtocol = (urlString, protocol) => {
switch (protocol) {
case "ws":
return urlString.replace(/^http/, "ws");
case "http":
return urlString.replace(/^ws/, "http");
}
};
const removeIndexString = (urlSting) => {

@@ -68,3 +77,4 @@ return urlSting.replace(/\/index$/, "");

removeIndexString,
replaceUrlParam
replaceUrlParam,
replaceUrlProtocol
});

@@ -22,3 +22,3 @@ "use strict";

__export(ssg_exports, {
SSG_DISABLED_RESPONSE: () => import_middleware.SSG_DISABLED_RESPONSE,
X_HONO_DISABLE_SSG_HEADER_KEY: () => import_middleware.X_HONO_DISABLE_SSG_HEADER_KEY,
disableSSG: () => import_middleware.disableSSG,

@@ -34,3 +34,3 @@ isSSGContext: () => import_middleware.isSSGContext,

0 && (module.exports = {
SSG_DISABLED_RESPONSE,
X_HONO_DISABLE_SSG_HEADER_KEY,
disableSSG,

@@ -37,0 +37,0 @@ isSSGContext,

@@ -23,2 +23,3 @@ "use strict";

SSG_DISABLED_RESPONSE: () => SSG_DISABLED_RESPONSE,
X_HONO_DISABLE_SSG_HEADER_KEY: () => X_HONO_DISABLE_SSG_HEADER_KEY,
disableSSG: () => disableSSG,

@@ -31,3 +32,13 @@ isSSGContext: () => isSSGContext,

const SSG_CONTEXT = "HONO_SSG_CONTEXT";
const SSG_DISABLED_RESPONSE = new Response("SSG is disabled", { status: 404 });
const X_HONO_DISABLE_SSG_HEADER_KEY = "x-hono-disable-ssg";
const SSG_DISABLED_RESPONSE = (() => {
try {
return new Response("SSG is disabled", {
status: 404,
headers: { [X_HONO_DISABLE_SSG_HEADER_KEY]: "true" }
});
} catch (e) {
return null;
}
})();
const ssgParams = (params) => async (c, next) => {

@@ -41,3 +52,4 @@ ;

if (isSSGContext(c)) {
return SSG_DISABLED_RESPONSE;
c.header(X_HONO_DISABLE_SSG_HEADER_KEY, "true");
return c.notFound();
}

@@ -56,2 +68,3 @@ await next();

SSG_DISABLED_RESPONSE,
X_HONO_DISABLE_SSG_HEADER_KEY,
disableSSG,

@@ -58,0 +71,0 @@ isSSGContext,

@@ -112,3 +112,3 @@ "use strict";

);
if (response === import_middleware.SSG_DISABLED_RESPONSE) {
if (response.headers.get(import_middleware.X_HONO_DISABLE_SSG_HEADER_KEY)) {
resolveReq(void 0);

@@ -115,0 +115,0 @@ return;

// src/client/client.ts
import { serialize } from "../utils/cookie.js";
import { deepMerge, mergePath, removeIndexString, replaceUrlParam } from "./utils.js";
import {
deepMerge,
mergePath,
removeIndexString,
replaceUrlParam,
replaceUrlProtocol
} from "./utils.js";
var createProxy = (callback, path) => {

@@ -115,3 +121,6 @@ const proxy = new Proxy(() => {

if (method === "ws") {
const targetUrl = opts.args[0] && opts.args[0].param ? replaceUrlParam(url, opts.args[0].param) : url;
const targetUrl = replaceUrlProtocol(
opts.args[0] && opts.args[0].param ? replaceUrlParam(url, opts.args[0].param) : url,
"ws"
);
return new WebSocket(targetUrl);

@@ -118,0 +127,0 @@ }

@@ -15,2 +15,10 @@ // src/client/utils.ts

};
var replaceUrlProtocol = (urlString, protocol) => {
switch (protocol) {
case "ws":
return urlString.replace(/^http/, "ws");
case "http":
return urlString.replace(/^ws/, "http");
}
};
var removeIndexString = (urlSting) => {

@@ -41,3 +49,4 @@ return urlSting.replace(/\/index$/, "");

removeIndexString,
replaceUrlParam
replaceUrlParam,
replaceUrlProtocol
};
// src/helper/ssg/index.ts
export * from "./ssg.js";
import { SSG_DISABLED_RESPONSE, ssgParams, isSSGContext, disableSSG, onlySSG } from "./middleware.js";
import {
X_HONO_DISABLE_SSG_HEADER_KEY,
ssgParams,
isSSGContext,
disableSSG,
onlySSG
} from "./middleware.js";
export {
SSG_DISABLED_RESPONSE,
X_HONO_DISABLE_SSG_HEADER_KEY,
disableSSG,

@@ -7,0 +13,0 @@ isSSGContext,

// src/helper/ssg/middleware.ts
var SSG_CONTEXT = "HONO_SSG_CONTEXT";
var SSG_DISABLED_RESPONSE = new Response("SSG is disabled", { status: 404 });
var X_HONO_DISABLE_SSG_HEADER_KEY = "x-hono-disable-ssg";
var SSG_DISABLED_RESPONSE = (() => {
try {
return new Response("SSG is disabled", {
status: 404,
headers: { [X_HONO_DISABLE_SSG_HEADER_KEY]: "true" }
});
} catch (e) {
return null;
}
})();
var ssgParams = (params) => async (c, next) => {

@@ -12,3 +22,4 @@ ;

if (isSSGContext(c)) {
return SSG_DISABLED_RESPONSE;
c.header(X_HONO_DISABLE_SSG_HEADER_KEY, "true");
return c.notFound();
}

@@ -26,2 +37,3 @@ await next();

SSG_DISABLED_RESPONSE,
X_HONO_DISABLE_SSG_HEADER_KEY,
disableSSG,

@@ -28,0 +40,0 @@ isSSGContext,

@@ -5,3 +5,3 @@ // src/helper/ssg/ssg.ts

import { getExtension } from "../../utils/mime.js";
import { SSG_DISABLED_RESPONSE, SSG_CONTEXT } from "./middleware.js";
import { X_HONO_DISABLE_SSG_HEADER_KEY, SSG_CONTEXT } from "./middleware.js";
import { joinPaths, dirname, filterStaticGenerateRoutes } from "./utils.js";

@@ -88,3 +88,3 @@ var DEFAULT_CONCURRENCY = 2;

);
if (response === SSG_DISABLED_RESPONSE) {
if (response.headers.get(X_HONO_DISABLE_SSG_HEADER_KEY)) {
resolveReq(void 0);

@@ -91,0 +91,0 @@ return;

export declare const mergePath: (base: string, path: string) => string;
export declare const replaceUrlParam: (urlString: string, params: Record<string, string>) => string;
export declare const replaceUrlProtocol: (urlString: string, protocol: 'ws' | 'http') => string;
export declare const removeIndexString: (urlSting: string) => string;
export declare function deepMerge<T>(target: T, source: Record<string, unknown>): T;
export * from './ssg';
export { SSG_DISABLED_RESPONSE, ssgParams, isSSGContext, disableSSG, onlySSG } from './middleware';
export { X_HONO_DISABLE_SSG_HEADER_KEY, ssgParams, isSSGContext, disableSSG, onlySSG, } from './middleware';
import type { Context } from '../../context';
import type { Env, MiddlewareHandler } from '../../types';
export declare const SSG_CONTEXT = "HONO_SSG_CONTEXT";
export declare const X_HONO_DISABLE_SSG_HEADER_KEY = "x-hono-disable-ssg";
/**
* @deprecated
* Use `X_HONO_DISABLE_SSG_HEADER_KEY` instead.
* This constant will be removed in the next minor version.
*/
export declare const SSG_DISABLED_RESPONSE: Response;

@@ -5,0 +11,0 @@ interface SSGParam {

{
"name": "hono",
"version": "4.2.2",
"version": "4.2.3",
"description": "Ultrafast web framework for the Edges",

@@ -385,2 +385,5 @@ "main": "dist/cjs/index.js",

],
"trailing-slash": [
"./dist/types/middleware/trailing-slash"
],
"html": [

@@ -387,0 +390,0 @@ "./dist/types/helper/html"

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