first commit
This commit is contained in:
49
app_vue/node_modules/@polka/url/build.js
generated
vendored
Normal file
49
app_vue/node_modules/@polka/url/build.js
generated
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
const qs = require('querystring');
|
||||
|
||||
/**
|
||||
* @typedef ParsedURL
|
||||
* @type {import('.').ParsedURL}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef Request
|
||||
* @property {string} url
|
||||
* @property {ParsedURL} _parsedUrl
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {Request} req
|
||||
* @returns {ParsedURL|void}
|
||||
*/
|
||||
function parse(req) {
|
||||
let raw = req.url;
|
||||
if (raw == null) return;
|
||||
|
||||
let prev = req._parsedUrl;
|
||||
if (prev && prev.raw === raw) return prev;
|
||||
|
||||
let pathname=raw, search='', query, hash;
|
||||
|
||||
if (raw.length > 1) {
|
||||
let idx = raw.indexOf('#', 1);
|
||||
|
||||
if (idx !== -1) {
|
||||
hash = raw.substring(idx);
|
||||
pathname = raw.substring(0, idx);
|
||||
}
|
||||
|
||||
idx = pathname.indexOf('?', 1);
|
||||
|
||||
if (idx !== -1) {
|
||||
search = pathname.substring(idx);
|
||||
pathname = pathname.substring(0, idx);
|
||||
if (search.length > 1) {
|
||||
query = qs.parse(search.substring(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return req._parsedUrl = { pathname, search, query, hash, raw };
|
||||
}
|
||||
|
||||
exports.parse = parse;
|
47
app_vue/node_modules/@polka/url/build.mjs
generated
vendored
Normal file
47
app_vue/node_modules/@polka/url/build.mjs
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
import * as qs from 'node:querystring';
|
||||
|
||||
/**
|
||||
* @typedef ParsedURL
|
||||
* @type {import('.').ParsedURL}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef Request
|
||||
* @property {string} url
|
||||
* @property {ParsedURL} _parsedUrl
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {Request} req
|
||||
* @returns {ParsedURL|void}
|
||||
*/
|
||||
export function parse(req) {
|
||||
let raw = req.url;
|
||||
if (raw == null) return;
|
||||
|
||||
let prev = req._parsedUrl;
|
||||
if (prev && prev.raw === raw) return prev;
|
||||
|
||||
let pathname=raw, search='', query, hash;
|
||||
|
||||
if (raw.length > 1) {
|
||||
let idx = raw.indexOf('#', 1);
|
||||
|
||||
if (idx !== -1) {
|
||||
hash = raw.substring(idx);
|
||||
pathname = raw.substring(0, idx);
|
||||
}
|
||||
|
||||
idx = pathname.indexOf('?', 1);
|
||||
|
||||
if (idx !== -1) {
|
||||
search = pathname.substring(idx);
|
||||
pathname = pathname.substring(0, idx);
|
||||
if (search.length > 1) {
|
||||
query = qs.parse(search.substring(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return req._parsedUrl = { pathname, search, query, hash, raw };
|
||||
}
|
11
app_vue/node_modules/@polka/url/index.d.ts
generated
vendored
Normal file
11
app_vue/node_modules/@polka/url/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
import type { IncomingMessage } from 'http';
|
||||
|
||||
export interface ParsedURL {
|
||||
pathname: string;
|
||||
search: string;
|
||||
query: Record<string, string | string[]> | undefined;
|
||||
hash: string | undefined;
|
||||
raw: string;
|
||||
}
|
||||
|
||||
export function parse(req: IncomingMessage): ParsedURL;
|
30
app_vue/node_modules/@polka/url/package.json
generated
vendored
Normal file
30
app_vue/node_modules/@polka/url/package.json
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"version": "1.0.0-next.29",
|
||||
"name": "@polka/url",
|
||||
"repository": "lukeed/polka",
|
||||
"description": "Super fast, memoized `req.url` parser",
|
||||
"module": "build.mjs",
|
||||
"types": "index.d.ts",
|
||||
"main": "build.js",
|
||||
"license": "MIT",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./index.d.ts",
|
||||
"import": "./build.mjs",
|
||||
"require": "./build.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"files": [
|
||||
"build.*",
|
||||
"index.d.*"
|
||||
],
|
||||
"author": {
|
||||
"name": "Luke Edwards",
|
||||
"email": "luke@lukeed.com",
|
||||
"url": "https://lukeed.com"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
68
app_vue/node_modules/@polka/url/readme.md
generated
vendored
Normal file
68
app_vue/node_modules/@polka/url/readme.md
generated
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
# @polka/url [](https://npmjs.org/package/@polka/url) [](https://licenses.dev/npm/%40polka%2Furl)
|
||||
|
||||
> Super fast, memoized `req.url` parser; _not_ limited to [Polka][polka]!
|
||||
|
||||
Parses the `url` from a [`IncomingMessage`](https://nodejs.org/api/http.html#http_class_http_incomingmessage) request. The returned object will always only contain the following keys: `search`, `query`, `pathname`, and `raw`.
|
||||
|
||||
> **Note:** This library does not process `protocol`, `hostname`, `port`, etc.<br>This is because the incoming `req.url` value only begins with the path information.
|
||||
|
||||
Parsed requests will be mutated with a `_parsedUrl` key, containing the returned output. This is used for future memoization, avoiding the need to fully parse the same `url` value multiple times.
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save @polka/url
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const parse = require('@polka/url');
|
||||
|
||||
let req = {
|
||||
url: '/foo/bar?fizz=buzz'
|
||||
};
|
||||
let output = parse(req);
|
||||
//=> {
|
||||
//=> pathname: '/foo/bar',
|
||||
//=> raw: '/foo/bar?fizz=buzz',
|
||||
//=> search: '?fizz=buzz',
|
||||
//=> query: {
|
||||
//=> fizz: 'buzz'
|
||||
//=> },
|
||||
//=> }
|
||||
|
||||
// Attaches result for future memoization
|
||||
assert.deepEqual(output, req._parsedUrl); //=> true
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### url(req)
|
||||
Returns: `Object` or `undefined`
|
||||
|
||||
> **Important:** The `req` must have a `url` key, otherwise `undefined` will be returned.<br>If no input is provided at all, a `TypeError` will be thrown.
|
||||
|
||||
#### req
|
||||
Type: `IncomingMessage` or `{ url: string }`
|
||||
|
||||
The incoming HTTP request (`req`) or a plain `Object` with a `url` key.
|
||||
|
||||
> **Note:** In Node.js servers, the [`req.url`](https://nodejs.org/api/http.html#http_message_url) begins with a pathname & does not include a `hash`.
|
||||
|
||||
|
||||
## Benchmarks
|
||||
|
||||
Check out the [`bench`](/bench) directory for in-depth benchmark results and comparisons.
|
||||
|
||||
|
||||
## Support
|
||||
|
||||
Any issues or questions can be sent to the [Polka][polka] repository.<br>However, please specify that your inquiry is about `@polka/url` specifically.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Luke Edwards](https://lukeed.com)
|
||||
|
||||
[polka]: https://github.com/lukeed/polka
|
Reference in New Issue
Block a user