@tinyhttp/res
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -1,4 +0,3 @@ | ||
/// <reference types="node/http.js" /> | ||
/// <reference types="node" /> | ||
import { ServerResponse as Res } from 'node:http'; | ||
export declare const append: <Response_1 extends Res<import("http").IncomingMessage> = Res<import("http").IncomingMessage>>(res: Response_1) => (field: string, value: string | number | string[]) => Response_1; | ||
//# sourceMappingURL=append.d.ts.map |
@@ -9,2 +9,1 @@ import { IncomingMessage as Req, ServerResponse as Res } from 'node:http'; | ||
export declare const clearCookie: <Request_1 extends Req = Req, Response_1 extends Res<Req> = Res<Req>>(req: Request_1, res: Response_1) => (name: string, options?: cookie.SerializeOptions) => Response_1; | ||
//# sourceMappingURL=cookie.d.ts.map |
@@ -10,2 +10,1 @@ import { IncomingMessage as Req, ServerResponse as Res } from 'node:http'; | ||
export {}; | ||
//# sourceMappingURL=download.d.ts.map |
@@ -13,2 +13,1 @@ import { IncomingMessage as Req, ServerResponse as Res } from 'node:http'; | ||
export {}; | ||
//# sourceMappingURL=format.d.ts.map |
@@ -10,2 +10,1 @@ import { IncomingMessage as Req, ServerResponse as Res } from 'node:http'; | ||
export declare const setContentType: <Response_1 extends Res<Req> = Res<Req>>(res: Response_1) => (type: string) => Response_1; | ||
//# sourceMappingURL=headers.d.ts.map |
@@ -9,2 +9,1 @@ export * from '@tinyhttp/send'; | ||
export { append } from './append.js'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -5,5 +5,5 @@ import { sendFile } from "@tinyhttp/send"; | ||
import { sign } from "@tinyhttp/cookie-signature"; | ||
import * as mime from "es-mime-types"; | ||
import mime from "mime"; | ||
import { getRequestHeader, getAccepts } from "@tinyhttp/req"; | ||
import { vary } from "es-vary"; | ||
import { vary } from "@tinyhttp/vary"; | ||
import { encodeUrl } from "@tinyhttp/encode-url"; | ||
@@ -13,3 +13,3 @@ import { STATUS_CODES } from "node:http"; | ||
import { contentDisposition } from "@tinyhttp/content-disposition"; | ||
import { resolve, extname } from "node:path"; | ||
import { basename, resolve, extname } from "node:path"; | ||
const charsetRegExp = /;\s*charset\s*=/; | ||
@@ -24,5 +24,4 @@ const setHeader = (res) => (field, val) => { | ||
if (!charsetRegExp.test(value)) { | ||
const charset = mime.charset(value.split(";")[0]); | ||
if (typeof charset === "string") | ||
value += "; charset=" + charset.toLowerCase(); | ||
const charset = "UTF-8"; | ||
value += "; charset=" + charset.toLowerCase(); | ||
} | ||
@@ -63,3 +62,3 @@ } | ||
const setContentType = (res) => (type) => { | ||
const ct = type.indexOf("/") === -1 ? mime.lookup(type) : type; | ||
const ct = type.indexOf("/") === -1 ? mime.getType(type) : type; | ||
setHeader(res)("Content-Type", ct); | ||
@@ -97,3 +96,3 @@ return res; | ||
}; | ||
const normalizeType = (type) => ~type.indexOf("/") ? acceptParams(type) : { value: mime.lookup(type), params: {} }; | ||
const normalizeType = (type) => ~type.indexOf("/") ? acceptParams(type) : { value: mime.getType(type), params: {} }; | ||
function acceptParams(str, index) { | ||
@@ -179,3 +178,3 @@ const parts = str.split(/ *; */); | ||
const headers = { | ||
"Content-Disposition": contentDisposition(name || path) | ||
"Content-Disposition": contentDisposition(name || basename(path)) | ||
}; | ||
@@ -192,4 +191,6 @@ if (opts && opts.headers) { | ||
const attachment = (res) => (filename) => { | ||
if (filename) | ||
if (filename) { | ||
setContentType(res)(extname(filename)); | ||
filename = basename(filename); | ||
} | ||
setHeader(res)("Content-Disposition", contentDisposition(filename)); | ||
@@ -213,1 +214,2 @@ return res; | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -5,2 +5,1 @@ import { IncomingMessage as Req, ServerResponse as Res } from 'node:http'; | ||
export {}; | ||
//# sourceMappingURL=redirect.d.ts.map |
@@ -10,2 +10,1 @@ export type NormalizedType = { | ||
export declare function normalizeTypes(types: string[]): NormalizedType[]; | ||
//# sourceMappingURL=util.d.ts.map |
{ | ||
"name": "@tinyhttp/res", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"type": "module", | ||
@@ -28,11 +28,11 @@ "description": "response extensions for tinyhttp", | ||
"dependencies": { | ||
"@tinyhttp/vary": "^0.1.3", | ||
"es-escape-html": "^0.1.1", | ||
"es-mime-types": "^0.1.4", | ||
"es-vary": "^0.1.2", | ||
"@tinyhttp/content-disposition": "2.1.0", | ||
"mime": "4.0.0-beta.1", | ||
"@tinyhttp/content-disposition": "2.2.0", | ||
"@tinyhttp/cookie": "2.1.0", | ||
"@tinyhttp/cookie-signature": "2.1.0", | ||
"@tinyhttp/req": "2.2.0", | ||
"@tinyhttp/encode-url": "2.1.0", | ||
"@tinyhttp/req": "2.1.0", | ||
"@tinyhttp/send": "2.1.0" | ||
"@tinyhttp/send": "2.2.0" | ||
}, | ||
@@ -39,0 +39,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
272
28214
14
+ Added@tinyhttp/vary@^0.1.3
+ Addedmime@4.0.0-beta.1
+ Added@tinyhttp/accepts@2.2.0(transitive)
+ Added@tinyhttp/content-disposition@2.2.0(transitive)
+ Added@tinyhttp/content-type@0.1.4(transitive)
+ Added@tinyhttp/req@2.2.0(transitive)
+ Added@tinyhttp/send@2.2.0(transitive)
+ Added@tinyhttp/type-is@2.2.0(transitive)
+ Added@tinyhttp/vary@0.1.3(transitive)
+ Addedmime@4.0.0-beta.1(transitive)
- Removedes-mime-types@^0.1.4
- Removedes-vary@^0.1.2
- Removed@tinyhttp/accepts@2.1.0(transitive)
- Removed@tinyhttp/content-disposition@2.1.0(transitive)
- Removed@tinyhttp/req@2.1.0(transitive)
- Removed@tinyhttp/send@2.1.0(transitive)
- Removed@tinyhttp/type-is@2.1.0(transitive)
- Removedes-content-type@0.1.0(transitive)
- Removedes-fresh@0.0.11(transitive)
- Removedes-mime-types@0.1.4(transitive)
- Removedes-vary@0.1.2(transitive)
- Removedmime-db@1.53.0(transitive)
Updated@tinyhttp/req@2.2.0
Updated@tinyhttp/send@2.2.0