added doga
This commit is contained in:
21
25_02_24/node_modules/@tinyhttp/vary/LICENSE
generated
vendored
Normal file
21
25_02_24/node_modules/@tinyhttp/vary/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 v 1 r t l
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
77
25_02_24/node_modules/@tinyhttp/vary/README.md
generated
vendored
Normal file
77
25_02_24/node_modules/@tinyhttp/vary/README.md
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
# @tinyhttp/vary
|
||||
|
||||
[![Version][v-badge-url]][npm-url] [![Downloads][dl-badge-url]][npm-url] [![GitHub Workflow Status][gh-actions-img]][github-actions] [![Codecov][cov-badge-url]][cov-url]
|
||||
|
||||
> [`vary`](https://github.com/jshttp/vary) rewrite in TypeScript with ESM and CommonJS targets
|
||||
|
||||
Manipulate the HTTP Vary header
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
pnpm i @tinyhttp/vary
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```ts
|
||||
import { vary, append } from '@tinyhttp/vary'
|
||||
```
|
||||
|
||||
### `vary(res, field)`
|
||||
|
||||
Adds the given header `field` to the `Vary` response header of `res`.
|
||||
This can be a string of a single field, a string of a valid `Vary`
|
||||
header, or an array of multiple fields.
|
||||
|
||||
This will append the header if not already listed, otherwise leaves
|
||||
it listed in the current location.
|
||||
|
||||
```ts
|
||||
vary(res, 'Origin')
|
||||
```
|
||||
|
||||
### `append(header, field)`
|
||||
|
||||
Adds the given header `field` to the `Vary` response header string `header`.
|
||||
This can be a string of a single field, a string of a valid `Vary` header,
|
||||
or an array of multiple fields.
|
||||
|
||||
This will append the header if not already listed, otherwise leaves
|
||||
it listed in the current location. The new header string is returned.
|
||||
|
||||
```ts
|
||||
// Get header string appending "Origin" to "Accept, User-Agent"
|
||||
append('Accept, User-Agent', 'Origin')
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
```ts
|
||||
import { createServer } from 'node:http'
|
||||
import { vary } from '@tinyhttp/vary'
|
||||
|
||||
createServer((req, res) => {
|
||||
// about to user-agent sniff
|
||||
vary(res, 'User-Agent')
|
||||
|
||||
const ua = req.headers['user-agent'] || ''
|
||||
const isMobile = /mobi|android|touch|mini/i.test(ua)
|
||||
|
||||
// serve site, depending on isMobile
|
||||
res.setHeader('Content-Type', 'text/html')
|
||||
res.end('You are (probably) ' + (isMobile ? '' : 'not ') + 'a mobile user')
|
||||
})
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT © [v1rtl](https://v1rtl.site)
|
||||
|
||||
[v-badge-url]: https://img.shields.io/npm/v/@tinyhttp/vary.svg?style=for-the-badge&color=FF69B4&label=&logo=npm
|
||||
[npm-url]: https://www.npmjs.com/package/@tinyhttp/vary
|
||||
[cov-badge-url]: https://img.shields.io/coveralls/github/tinyhttp/vary?style=for-the-badge&color=FF69B4
|
||||
[cov-url]: https://coveralls.io/github/tinyhttp/vary
|
||||
[dl-badge-url]: https://img.shields.io/npm/dt/@tinyhttp/vary?style=for-the-badge&color=FF69B4
|
||||
[github-actions]: https://github.com/tinyhttp/vary/actions
|
||||
[gh-actions-img]: https://img.shields.io/github/actions/workflow/status/tinyhttp/vary/main.yml?branch=master&style=for-the-badge&color=FF69B4&label=&logo=github
|
||||
9
25_02_24/node_modules/@tinyhttp/vary/dist/index.d.ts
generated
vendored
Normal file
9
25_02_24/node_modules/@tinyhttp/vary/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { ServerResponse } from 'node:http';
|
||||
|
||||
declare function append(header: string, field: string | string[]): string;
|
||||
/**
|
||||
* Mark that a request is varied on a header field.
|
||||
*/
|
||||
declare function vary(res: ServerResponse, field: string | string[]): void;
|
||||
|
||||
export { append, vary };
|
||||
1
25_02_24/node_modules/@tinyhttp/vary/dist/index.js
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/vary/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var FIELD_NAME_REGEXP=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function parse(header){let end=0;const list=[];let start=0;for(let i=0,len=header.length;i<len;i++){switch(header.charCodeAt(i)){case 32:if(start===end){start=end=i+1}break;case 44:list.push(header.substring(start,end));start=end=i+1;break;default:end=i+1;break}}list.push(header.substring(start,end));return list}function append(header,field){const fields=!Array.isArray(field)?parse(String(field)):field;for(const field2 of fields){if(!FIELD_NAME_REGEXP.test(field2))throw new TypeError("field argument contains an invalid header name")}if(header==="*"){return header}let val=header;const vals=parse(header.toLowerCase());if(fields.indexOf("*")!==-1||vals.indexOf("*")!==-1){return"*"}for(const field2 of fields){const fld=field2.toLowerCase();if(vals.indexOf(fld)===-1){vals.push(fld);val=val?val+", "+field2:field2}}return val}function vary(res,field){let val=res.getHeader("Vary")||"";const header=Array.isArray(val)?val.join(", "):String(val);if(val=append(header,field)){res.setHeader("Vary",val)}}export{append,vary};
|
||||
51
25_02_24/node_modules/@tinyhttp/vary/package.json
generated
vendored
Normal file
51
25_02_24/node_modules/@tinyhttp/vary/package.json
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"name": "@tinyhttp/vary",
|
||||
"description": "vary rewrite in TypeScript and ESM",
|
||||
"version": "0.1.3",
|
||||
"type": "module",
|
||||
"exports": "./dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"engines": {
|
||||
"node": ">=12.20"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/tinyhttp/vary.git"
|
||||
},
|
||||
"keywords": [
|
||||
"http",
|
||||
"esm",
|
||||
"es",
|
||||
"vary",
|
||||
"nodejs",
|
||||
"javascript"
|
||||
],
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"author": "v1rtl <hi@v1rtl.site>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/tinyhttp/vary/issues"
|
||||
},
|
||||
"homepage": "https://github.com/tinyhttp/vary#readme",
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.7.1",
|
||||
"@typescript-eslint/eslint-plugin": "^6.7.3",
|
||||
"@typescript-eslint/parser": "^6.7.3",
|
||||
"c8": "^8.0.1",
|
||||
"tsm": "^2.3.0",
|
||||
"tsup": "^7.2.0",
|
||||
"typescript": "^5.2.2",
|
||||
"uvu": "^0.5.6"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsup src/index.ts --minify-whitespace --format esm --dts",
|
||||
"test": "tsm node_modules/uvu/bin.js test",
|
||||
"test:coverage": "c8 --include=src pnpm test",
|
||||
"test:report": "c8 report --reporter=text-lcov > coverage.lcov"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user