New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

htmx-router

Package Overview
Dependencies
Maintainers
0
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

htmx-router - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

5

internal/request/native.js

@@ -23,4 +23,7 @@ import { ServerOnlyWarning } from "../util.js";

if (response.headers !== ctx.headers) {
for (const [key, value] of ctx.headers)
for (const [key, value] of ctx.headers) {
if (key === "content-type")
continue;
response.headers.set(key, value);
}
}

@@ -27,0 +30,0 @@ }

1

internal/util.d.ts

@@ -5,1 +5,2 @@ export declare function QuickHash(input: string): string;

export declare function ServerOnlyWarning(context: string): void;
export declare function AssertUnreachable(x: never): never;

@@ -50,1 +50,5 @@ export function QuickHash(input) {

}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function AssertUnreachable(x) {
throw new Error("Unreachable code path reachable");
}
{
"name": "htmx-router",
"version": "1.0.5",
"version": "1.0.6",
"description": "A lightweight SSR framework with server+client islands",

@@ -5,0 +5,0 @@ "keywords": [

@@ -1,3 +0,3 @@

export declare function text(text: string, init?: ResponseInit): Response;
export declare function html(text: string, init?: ResponseInit): Response;
export declare function text(text: BodyInit, init?: ResponseInit): Response;
export declare function html(text: BodyInit, init?: ResponseInit): Response;
export type TypedResponse<T> = Omit<Response, "json"> & {

@@ -4,0 +4,0 @@ json(): Promise<T>;

@@ -1,3 +0,4 @@

import { ServerOnlyWarning } from "./internal/util.js";
import { AssertUnreachable, ServerOnlyWarning } from "./internal/util.js";
ServerOnlyWarning("router");
import { MakeStatus } from "./status.js";
// builtin routes

@@ -8,2 +9,3 @@ import * as endpoint from './endpoint.js';

import * as css from './css.js';
import { html } from "./response.js";
export function GenerateRouteTree(props) {

@@ -138,3 +140,3 @@ if (!props.scope.endsWith("/"))

return null;
return new Response(res, { headers: ctx.headers });
AssertUnreachable(res);
}

@@ -166,18 +168,8 @@ async resolveNext(fragments, ctx) {

return null;
return new Response(res, { headers: ctx.headers });
AssertUnreachable(res);
}
async unwrap(ctx, res) {
unwrap(ctx, res) {
if (!this.slug)
throw res;
const caught = await this.slug.error(ctx, res);
if (caught instanceof Response) {
caught.headers.set("X-Caught", "true");
return caught;
}
ctx.headers.set("X-Caught", "true");
return new Response(caught, res instanceof Response ? res : {
status: 500,
statusText: "Internal Server Error",
headers: ctx.headers
});
return this.slug.error(ctx, res);
}

@@ -191,8 +183,11 @@ }

async resolve(ctx) {
const res = await this.response(ctx);
if (res === null)
const jsx = await this.response(ctx);
if (jsx === null)
return null;
if (jsx instanceof Response)
return jsx;
const res = await ctx.render(jsx, ctx.headers);
if (res instanceof Response)
return res;
return await ctx.render(res, ctx.headers);
return html(res, { headers: ctx.headers });
}

@@ -202,6 +197,11 @@ async error(ctx, e) {

throw e;
const res = await this.module.error(ctx, e);
if (res instanceof Response)
return res;
return await ctx.render(res, ctx.headers);
let jsx = await this.module.error(ctx, e);
const caught = jsx instanceof Response ? jsx
: await ctx.render(jsx, ctx.headers);
if (caught instanceof Response) {
caught.headers.set("X-Caught", "true");
return caught;
}
ctx.headers.set("X-Caught", "true");
return html(caught, e instanceof Response ? e : MakeStatus("Internal Server Error", ctx.headers));
}

@@ -221,3 +221,3 @@ async response(ctx) {

return await this.module.action(context);
throw new Response("Method not Allowed", { status: 405, statusText: "Method not Allowed", headers: ctx.headers });
throw new Response("Method not Allowed", MakeStatus("Method Not Allowed", ctx.headers));
}

@@ -224,0 +224,0 @@ catch (e) {

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