Update checked-in dependencies
This commit is contained in:
parent
4b72bef651
commit
dbb232a3d8
1389 changed files with 209949 additions and 542 deletions
19
node_modules/jsdom/node_modules/form-data/License
generated
vendored
Normal file
19
node_modules/jsdom/node_modules/form-data/License
generated
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
Copyright (c) 2012 Felix Geisendörfer (felix@debuggable.com) and contributors
|
||||
|
||||
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.
|
||||
358
node_modules/jsdom/node_modules/form-data/Readme.md
generated
vendored
Normal file
358
node_modules/jsdom/node_modules/form-data/Readme.md
generated
vendored
Normal file
|
|
@ -0,0 +1,358 @@
|
|||
# Form-Data [](https://www.npmjs.com/package/form-data) [](https://gitter.im/form-data/form-data)
|
||||
|
||||
A library to create readable ```"multipart/form-data"``` streams. Can be used to submit forms and file uploads to other web applications.
|
||||
|
||||
The API of this library is inspired by the [XMLHttpRequest-2 FormData Interface][xhr2-fd].
|
||||
|
||||
[xhr2-fd]: http://dev.w3.org/2006/webapi/XMLHttpRequest-2/Overview.html#the-formdata-interface
|
||||
|
||||
[](https://travis-ci.org/form-data/form-data)
|
||||
[](https://travis-ci.org/form-data/form-data)
|
||||
[](https://travis-ci.org/form-data/form-data)
|
||||
|
||||
[](https://coveralls.io/github/form-data/form-data?branch=master)
|
||||
[](https://david-dm.org/form-data/form-data)
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
npm install --save form-data
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
In this example we are constructing a form with 3 fields that contain a string,
|
||||
a buffer and a file stream.
|
||||
|
||||
``` javascript
|
||||
var FormData = require('form-data');
|
||||
var fs = require('fs');
|
||||
|
||||
var form = new FormData();
|
||||
form.append('my_field', 'my value');
|
||||
form.append('my_buffer', new Buffer(10));
|
||||
form.append('my_file', fs.createReadStream('/foo/bar.jpg'));
|
||||
```
|
||||
|
||||
Also you can use http-response stream:
|
||||
|
||||
``` javascript
|
||||
var FormData = require('form-data');
|
||||
var http = require('http');
|
||||
|
||||
var form = new FormData();
|
||||
|
||||
http.request('http://nodejs.org/images/logo.png', function(response) {
|
||||
form.append('my_field', 'my value');
|
||||
form.append('my_buffer', new Buffer(10));
|
||||
form.append('my_logo', response);
|
||||
});
|
||||
```
|
||||
|
||||
Or @mikeal's [request](https://github.com/request/request) stream:
|
||||
|
||||
``` javascript
|
||||
var FormData = require('form-data');
|
||||
var request = require('request');
|
||||
|
||||
var form = new FormData();
|
||||
|
||||
form.append('my_field', 'my value');
|
||||
form.append('my_buffer', new Buffer(10));
|
||||
form.append('my_logo', request('http://nodejs.org/images/logo.png'));
|
||||
```
|
||||
|
||||
In order to submit this form to a web application, call ```submit(url, [callback])``` method:
|
||||
|
||||
``` javascript
|
||||
form.submit('http://example.org/', function(err, res) {
|
||||
// res – response object (http.IncomingMessage) //
|
||||
res.resume();
|
||||
});
|
||||
|
||||
```
|
||||
|
||||
For more advanced request manipulations ```submit()``` method returns ```http.ClientRequest``` object, or you can choose from one of the alternative submission methods.
|
||||
|
||||
### Custom options
|
||||
|
||||
You can provide custom options, such as `maxDataSize`:
|
||||
|
||||
``` javascript
|
||||
var FormData = require('form-data');
|
||||
|
||||
var form = new FormData({ maxDataSize: 20971520 });
|
||||
form.append('my_field', 'my value');
|
||||
form.append('my_buffer', /* something big */);
|
||||
```
|
||||
|
||||
List of available options could be found in [combined-stream](https://github.com/felixge/node-combined-stream/blob/master/lib/combined_stream.js#L7-L15)
|
||||
|
||||
### Alternative submission methods
|
||||
|
||||
You can use node's http client interface:
|
||||
|
||||
``` javascript
|
||||
var http = require('http');
|
||||
|
||||
var request = http.request({
|
||||
method: 'post',
|
||||
host: 'example.org',
|
||||
path: '/upload',
|
||||
headers: form.getHeaders()
|
||||
});
|
||||
|
||||
form.pipe(request);
|
||||
|
||||
request.on('response', function(res) {
|
||||
console.log(res.statusCode);
|
||||
});
|
||||
```
|
||||
|
||||
Or if you would prefer the `'Content-Length'` header to be set for you:
|
||||
|
||||
``` javascript
|
||||
form.submit('example.org/upload', function(err, res) {
|
||||
console.log(res.statusCode);
|
||||
});
|
||||
```
|
||||
|
||||
To use custom headers and pre-known length in parts:
|
||||
|
||||
``` javascript
|
||||
var CRLF = '\r\n';
|
||||
var form = new FormData();
|
||||
|
||||
var options = {
|
||||
header: CRLF + '--' + form.getBoundary() + CRLF + 'X-Custom-Header: 123' + CRLF + CRLF,
|
||||
knownLength: 1
|
||||
};
|
||||
|
||||
form.append('my_buffer', buffer, options);
|
||||
|
||||
form.submit('http://example.com/', function(err, res) {
|
||||
if (err) throw err;
|
||||
console.log('Done');
|
||||
});
|
||||
```
|
||||
|
||||
Form-Data can recognize and fetch all the required information from common types of streams (```fs.readStream```, ```http.response``` and ```mikeal's request```), for some other types of streams you'd need to provide "file"-related information manually:
|
||||
|
||||
``` javascript
|
||||
someModule.stream(function(err, stdout, stderr) {
|
||||
if (err) throw err;
|
||||
|
||||
var form = new FormData();
|
||||
|
||||
form.append('file', stdout, {
|
||||
filename: 'unicycle.jpg', // ... or:
|
||||
filepath: 'photos/toys/unicycle.jpg',
|
||||
contentType: 'image/jpeg',
|
||||
knownLength: 19806
|
||||
});
|
||||
|
||||
form.submit('http://example.com/', function(err, res) {
|
||||
if (err) throw err;
|
||||
console.log('Done');
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
The `filepath` property overrides `filename` and may contain a relative path. This is typically used when uploading [multiple files from a directory](https://wicg.github.io/entries-api/#dom-htmlinputelement-webkitdirectory).
|
||||
|
||||
For edge cases, like POST request to URL with query string or to pass HTTP auth credentials, object can be passed to `form.submit()` as first parameter:
|
||||
|
||||
``` javascript
|
||||
form.submit({
|
||||
host: 'example.com',
|
||||
path: '/probably.php?extra=params',
|
||||
auth: 'username:password'
|
||||
}, function(err, res) {
|
||||
console.log(res.statusCode);
|
||||
});
|
||||
```
|
||||
|
||||
In case you need to also send custom HTTP headers with the POST request, you can use the `headers` key in first parameter of `form.submit()`:
|
||||
|
||||
``` javascript
|
||||
form.submit({
|
||||
host: 'example.com',
|
||||
path: '/surelynot.php',
|
||||
headers: {'x-test-header': 'test-header-value'}
|
||||
}, function(err, res) {
|
||||
console.log(res.statusCode);
|
||||
});
|
||||
```
|
||||
|
||||
### Methods
|
||||
|
||||
- [_Void_ append( **String** _field_, **Mixed** _value_ [, **Mixed** _options_] )](https://github.com/form-data/form-data#void-append-string-field-mixed-value--mixed-options-).
|
||||
- [_Headers_ getHeaders( [**Headers** _userHeaders_] )](https://github.com/form-data/form-data#array-getheaders-array-userheaders-)
|
||||
- [_String_ getBoundary()](https://github.com/form-data/form-data#string-getboundary)
|
||||
- [_Void_ setBoundary()](https://github.com/form-data/form-data#void-setboundary)
|
||||
- [_Buffer_ getBuffer()](https://github.com/form-data/form-data#buffer-getbuffer)
|
||||
- [_Integer_ getLengthSync()](https://github.com/form-data/form-data#integer-getlengthsync)
|
||||
- [_Integer_ getLength( **function** _callback_ )](https://github.com/form-data/form-data#integer-getlength-function-callback-)
|
||||
- [_Boolean_ hasKnownLength()](https://github.com/form-data/form-data#boolean-hasknownlength)
|
||||
- [_Request_ submit( _params_, **function** _callback_ )](https://github.com/form-data/form-data#request-submit-params-function-callback-)
|
||||
- [_String_ toString()](https://github.com/form-data/form-data#string-tostring)
|
||||
|
||||
#### _Void_ append( **String** _field_, **Mixed** _value_ [, **Mixed** _options_] )
|
||||
Append data to the form. You can submit about any format (string, integer, boolean, buffer, etc.). However, Arrays are not supported and need to be turned into strings by the user.
|
||||
```javascript
|
||||
var form = new FormData();
|
||||
form.append( 'my_string', 'my value' );
|
||||
form.append( 'my_integer', 1 );
|
||||
form.append( 'my_boolean', true );
|
||||
form.append( 'my_buffer', new Buffer(10) );
|
||||
form.append( 'my_array_as_json', JSON.stringify( ['bird','cute'] ) )
|
||||
```
|
||||
|
||||
You may provide a string for options, or an object.
|
||||
```javascript
|
||||
// Set filename by providing a string for options
|
||||
form.append( 'my_file', fs.createReadStream('/foo/bar.jpg'), 'bar.jpg' );
|
||||
|
||||
// provide an object.
|
||||
form.append( 'my_file', fs.createReadStream('/foo/bar.jpg'), {filename: 'bar.jpg', contentType: 'image/jpeg', knownLength: 19806} );
|
||||
```
|
||||
|
||||
#### _Headers_ getHeaders( [**Headers** _userHeaders_] )
|
||||
This method adds the correct `content-type` header to the provided array of `userHeaders`.
|
||||
|
||||
#### _String_ getBoundary()
|
||||
Return the boundary of the formData. By default, the boundary consists of 26 `-` followed by 24 numbers
|
||||
for example:
|
||||
```javascript
|
||||
--------------------------515890814546601021194782
|
||||
```
|
||||
|
||||
#### _Void_ setBoundary(String _boundary_)
|
||||
Set the boundary string, overriding the default behavior described above.
|
||||
|
||||
_Note: The boundary must be unique and may not appear in the data._
|
||||
|
||||
#### _Buffer_ getBuffer()
|
||||
Return the full formdata request package, as a Buffer. You can insert this Buffer in e.g. Axios to send multipart data.
|
||||
```javascript
|
||||
var form = new FormData();
|
||||
form.append( 'my_buffer', Buffer.from([0x4a,0x42,0x20,0x52,0x6f,0x63,0x6b,0x73]) );
|
||||
form.append( 'my_file', fs.readFileSync('/foo/bar.jpg') );
|
||||
|
||||
axios.post( 'https://example.com/path/to/api',
|
||||
form.getBuffer(),
|
||||
form.getHeaders()
|
||||
)
|
||||
```
|
||||
**Note:** Because the output is of type Buffer, you can only append types that are accepted by Buffer: *string, Buffer, ArrayBuffer, Array, or Array-like Object*. A ReadStream for example will result in an error.
|
||||
|
||||
#### _Integer_ getLengthSync()
|
||||
Same as `getLength` but synchronous.
|
||||
|
||||
_Note: getLengthSync __doesn't__ calculate streams length._
|
||||
|
||||
#### _Integer_ getLength( **function** _callback_ )
|
||||
Returns the `Content-Length` async. The callback is used to handle errors and continue once the length has been calculated
|
||||
```javascript
|
||||
this.getLength(function(err, length) {
|
||||
if (err) {
|
||||
this._error(err);
|
||||
return;
|
||||
}
|
||||
|
||||
// add content length
|
||||
request.setHeader('Content-Length', length);
|
||||
|
||||
...
|
||||
}.bind(this));
|
||||
```
|
||||
|
||||
#### _Boolean_ hasKnownLength()
|
||||
Checks if the length of added values is known.
|
||||
|
||||
#### _Request_ submit( _params_, **function** _callback_ )
|
||||
Submit the form to a web application.
|
||||
```javascript
|
||||
var form = new FormData();
|
||||
form.append( 'my_string', 'Hello World' );
|
||||
|
||||
form.submit( 'http://example.com/', function(err, res) {
|
||||
// res – response object (http.IncomingMessage) //
|
||||
res.resume();
|
||||
} );
|
||||
```
|
||||
|
||||
#### _String_ toString()
|
||||
Returns the form data as a string. Don't use this if you are sending files or buffers, use `getBuffer()` instead.
|
||||
|
||||
### Integration with other libraries
|
||||
|
||||
#### Request
|
||||
|
||||
Form submission using [request](https://github.com/request/request):
|
||||
|
||||
```javascript
|
||||
var formData = {
|
||||
my_field: 'my_value',
|
||||
my_file: fs.createReadStream(__dirname + '/unicycle.jpg'),
|
||||
};
|
||||
|
||||
request.post({url:'http://service.com/upload', formData: formData}, function(err, httpResponse, body) {
|
||||
if (err) {
|
||||
return console.error('upload failed:', err);
|
||||
}
|
||||
console.log('Upload successful! Server responded with:', body);
|
||||
});
|
||||
```
|
||||
|
||||
For more details see [request readme](https://github.com/request/request#multipartform-data-multipart-form-uploads).
|
||||
|
||||
#### node-fetch
|
||||
|
||||
You can also submit a form using [node-fetch](https://github.com/bitinn/node-fetch):
|
||||
|
||||
```javascript
|
||||
var form = new FormData();
|
||||
|
||||
form.append('a', 1);
|
||||
|
||||
fetch('http://example.com', { method: 'POST', body: form })
|
||||
.then(function(res) {
|
||||
return res.json();
|
||||
}).then(function(json) {
|
||||
console.log(json);
|
||||
});
|
||||
```
|
||||
|
||||
#### axios
|
||||
|
||||
In Node.js you can post a file using [axios](https://github.com/axios/axios):
|
||||
```javascript
|
||||
const form = new FormData();
|
||||
const stream = fs.createReadStream(PATH_TO_FILE);
|
||||
|
||||
form.append('image', stream);
|
||||
|
||||
// In Node.js environment you need to set boundary in the header field 'Content-Type' by calling method `getHeaders`
|
||||
const formHeaders = form.getHeaders();
|
||||
|
||||
axios.post('http://example.com', form, {
|
||||
headers: {
|
||||
...formHeaders,
|
||||
},
|
||||
})
|
||||
.then(response => response)
|
||||
.catch(error => error)
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- ```getLengthSync()``` method DOESN'T calculate length for streams, use ```knownLength``` options as workaround.
|
||||
- ```getLength(cb)``` will send an error as first parameter of callback if stream length cannot be calculated (e.g. send in custom streams w/o using ```knownLength```).
|
||||
- ```submit``` will not add `content-length` if form length is unknown or not calculable.
|
||||
- Starting version `2.x` FormData has dropped support for `node@0.10.x`.
|
||||
- Starting version `3.x` FormData has dropped support for `node@4.x`.
|
||||
|
||||
## License
|
||||
|
||||
Form-Data is released under the [MIT](License) license.
|
||||
62
node_modules/jsdom/node_modules/form-data/index.d.ts
generated
vendored
Normal file
62
node_modules/jsdom/node_modules/form-data/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
// Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>
|
||||
// Leon Yu <https://github.com/leonyu>
|
||||
// BendingBender <https://github.com/BendingBender>
|
||||
// Maple Miao <https://github.com/mapleeit>
|
||||
|
||||
/// <reference types="node" />
|
||||
import * as stream from 'stream';
|
||||
import * as http from 'http';
|
||||
|
||||
export = FormData;
|
||||
|
||||
// Extracted because @types/node doesn't export interfaces.
|
||||
interface ReadableOptions {
|
||||
highWaterMark?: number;
|
||||
encoding?: string;
|
||||
objectMode?: boolean;
|
||||
read?(this: stream.Readable, size: number): void;
|
||||
destroy?(this: stream.Readable, error: Error | null, callback: (error: Error | null) => void): void;
|
||||
autoDestroy?: boolean;
|
||||
}
|
||||
|
||||
interface Options extends ReadableOptions {
|
||||
writable?: boolean;
|
||||
readable?: boolean;
|
||||
dataSize?: number;
|
||||
maxDataSize?: number;
|
||||
pauseStreams?: boolean;
|
||||
}
|
||||
|
||||
declare class FormData extends stream.Readable {
|
||||
constructor(options?: Options);
|
||||
append(key: string, value: any, options?: FormData.AppendOptions | string): void;
|
||||
getHeaders(userHeaders?: FormData.Headers): FormData.Headers;
|
||||
submit(
|
||||
params: string | FormData.SubmitOptions,
|
||||
callback?: (error: Error | null, response: http.IncomingMessage) => void
|
||||
): http.ClientRequest;
|
||||
getBuffer(): Buffer;
|
||||
setBoundary(boundary: string): void;
|
||||
getBoundary(): string;
|
||||
getLength(callback: (err: Error | null, length: number) => void): void;
|
||||
getLengthSync(): number;
|
||||
hasKnownLength(): boolean;
|
||||
}
|
||||
|
||||
declare namespace FormData {
|
||||
interface Headers {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
interface AppendOptions {
|
||||
header?: string | Headers;
|
||||
knownLength?: number;
|
||||
filename?: string;
|
||||
filepath?: string;
|
||||
contentType?: string;
|
||||
}
|
||||
|
||||
interface SubmitOptions extends http.RequestOptions {
|
||||
protocol?: 'https:' | 'http:';
|
||||
}
|
||||
}
|
||||
2
node_modules/jsdom/node_modules/form-data/lib/browser.js
generated
vendored
Normal file
2
node_modules/jsdom/node_modules/form-data/lib/browser.js
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
/* eslint-env browser */
|
||||
module.exports = typeof self == 'object' ? self.FormData : window.FormData;
|
||||
503
node_modules/jsdom/node_modules/form-data/lib/form_data.js
generated
vendored
Normal file
503
node_modules/jsdom/node_modules/form-data/lib/form_data.js
generated
vendored
Normal file
|
|
@ -0,0 +1,503 @@
|
|||
var CombinedStream = require('combined-stream');
|
||||
var util = require('util');
|
||||
var path = require('path');
|
||||
var http = require('http');
|
||||
var https = require('https');
|
||||
var parseUrl = require('url').parse;
|
||||
var fs = require('fs');
|
||||
var Stream = require('stream').Stream;
|
||||
var mime = require('mime-types');
|
||||
var asynckit = require('asynckit');
|
||||
var setToStringTag = require('es-set-tostringtag');
|
||||
var populate = require('./populate.js');
|
||||
|
||||
// Public API
|
||||
module.exports = FormData;
|
||||
|
||||
// make it a Stream
|
||||
util.inherits(FormData, CombinedStream);
|
||||
|
||||
/**
|
||||
* Create readable "multipart/form-data" streams.
|
||||
* Can be used to submit forms
|
||||
* and file uploads to other web applications.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} options - Properties to be added/overriden for FormData and CombinedStream
|
||||
*/
|
||||
function FormData(options) {
|
||||
if (!(this instanceof FormData)) {
|
||||
return new FormData(options);
|
||||
}
|
||||
|
||||
this._overheadLength = 0;
|
||||
this._valueLength = 0;
|
||||
this._valuesToMeasure = [];
|
||||
|
||||
CombinedStream.call(this);
|
||||
|
||||
options = options || {};
|
||||
for (var option in options) {
|
||||
this[option] = options[option];
|
||||
}
|
||||
}
|
||||
|
||||
FormData.LINE_BREAK = '\r\n';
|
||||
FormData.DEFAULT_CONTENT_TYPE = 'application/octet-stream';
|
||||
|
||||
FormData.prototype.append = function(field, value, options) {
|
||||
|
||||
options = options || {};
|
||||
|
||||
// allow filename as single option
|
||||
if (typeof options == 'string') {
|
||||
options = {filename: options};
|
||||
}
|
||||
|
||||
var append = CombinedStream.prototype.append.bind(this);
|
||||
|
||||
// all that streamy business can't handle numbers
|
||||
if (typeof value == 'number') {
|
||||
value = '' + value;
|
||||
}
|
||||
|
||||
// https://github.com/felixge/node-form-data/issues/38
|
||||
if (Array.isArray(value)) {
|
||||
// Please convert your array into string
|
||||
// the way web server expects it
|
||||
this._error(new Error('Arrays are not supported.'));
|
||||
return;
|
||||
}
|
||||
|
||||
var header = this._multiPartHeader(field, value, options);
|
||||
var footer = this._multiPartFooter();
|
||||
|
||||
append(header);
|
||||
append(value);
|
||||
append(footer);
|
||||
|
||||
// pass along options.knownLength
|
||||
this._trackLength(header, value, options);
|
||||
};
|
||||
|
||||
FormData.prototype._trackLength = function(header, value, options) {
|
||||
var valueLength = 0;
|
||||
|
||||
// used w/ getLengthSync(), when length is known.
|
||||
// e.g. for streaming directly from a remote server,
|
||||
// w/ a known file a size, and not wanting to wait for
|
||||
// incoming file to finish to get its size.
|
||||
if (options.knownLength != null) {
|
||||
valueLength += +options.knownLength;
|
||||
} else if (Buffer.isBuffer(value)) {
|
||||
valueLength = value.length;
|
||||
} else if (typeof value === 'string') {
|
||||
valueLength = Buffer.byteLength(value);
|
||||
}
|
||||
|
||||
this._valueLength += valueLength;
|
||||
|
||||
// @check why add CRLF? does this account for custom/multiple CRLFs?
|
||||
this._overheadLength +=
|
||||
Buffer.byteLength(header) +
|
||||
FormData.LINE_BREAK.length;
|
||||
|
||||
// empty or either doesn't have path or not an http response or not a stream
|
||||
if (!value || ( !value.path && !(value.readable && Object.prototype.hasOwnProperty.call(value, 'httpVersion')) && !(value instanceof Stream))) {
|
||||
return;
|
||||
}
|
||||
|
||||
// no need to bother with the length
|
||||
if (!options.knownLength) {
|
||||
this._valuesToMeasure.push(value);
|
||||
}
|
||||
};
|
||||
|
||||
FormData.prototype._lengthRetriever = function(value, callback) {
|
||||
if (Object.prototype.hasOwnProperty.call(value, 'fd')) {
|
||||
|
||||
// take read range into a account
|
||||
// `end` = Infinity –> read file till the end
|
||||
//
|
||||
// TODO: Looks like there is bug in Node fs.createReadStream
|
||||
// it doesn't respect `end` options without `start` options
|
||||
// Fix it when node fixes it.
|
||||
// https://github.com/joyent/node/issues/7819
|
||||
if (value.end != undefined && value.end != Infinity && value.start != undefined) {
|
||||
|
||||
// when end specified
|
||||
// no need to calculate range
|
||||
// inclusive, starts with 0
|
||||
callback(null, value.end + 1 - (value.start ? value.start : 0));
|
||||
|
||||
// not that fast snoopy
|
||||
} else {
|
||||
// still need to fetch file size from fs
|
||||
fs.stat(value.path, function(err, stat) {
|
||||
|
||||
var fileSize;
|
||||
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
|
||||
// update final size based on the range options
|
||||
fileSize = stat.size - (value.start ? value.start : 0);
|
||||
callback(null, fileSize);
|
||||
});
|
||||
}
|
||||
|
||||
// or http response
|
||||
} else if (Object.prototype.hasOwnProperty.call(value, 'httpVersion')) {
|
||||
callback(null, +value.headers['content-length']);
|
||||
|
||||
// or request stream http://github.com/mikeal/request
|
||||
} else if (Object.prototype.hasOwnProperty.call(value, 'httpModule')) {
|
||||
// wait till response come back
|
||||
value.on('response', function(response) {
|
||||
value.pause();
|
||||
callback(null, +response.headers['content-length']);
|
||||
});
|
||||
value.resume();
|
||||
|
||||
// something else
|
||||
} else {
|
||||
callback('Unknown stream');
|
||||
}
|
||||
};
|
||||
|
||||
FormData.prototype._multiPartHeader = function(field, value, options) {
|
||||
// custom header specified (as string)?
|
||||
// it becomes responsible for boundary
|
||||
// (e.g. to handle extra CRLFs on .NET servers)
|
||||
if (typeof options.header == 'string') {
|
||||
return options.header;
|
||||
}
|
||||
|
||||
var contentDisposition = this._getContentDisposition(value, options);
|
||||
var contentType = this._getContentType(value, options);
|
||||
|
||||
var contents = '';
|
||||
var headers = {
|
||||
// add custom disposition as third element or keep it two elements if not
|
||||
'Content-Disposition': ['form-data', 'name="' + field + '"'].concat(contentDisposition || []),
|
||||
// if no content type. allow it to be empty array
|
||||
'Content-Type': [].concat(contentType || [])
|
||||
};
|
||||
|
||||
// allow custom headers.
|
||||
if (typeof options.header == 'object') {
|
||||
populate(headers, options.header);
|
||||
}
|
||||
|
||||
var header;
|
||||
for (var prop in headers) {
|
||||
if (Object.prototype.hasOwnProperty.call(headers, prop)) {
|
||||
header = headers[prop];
|
||||
|
||||
// skip nullish headers.
|
||||
if (header == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// convert all headers to arrays.
|
||||
if (!Array.isArray(header)) {
|
||||
header = [header];
|
||||
}
|
||||
|
||||
// add non-empty headers.
|
||||
if (header.length) {
|
||||
contents += prop + ': ' + header.join('; ') + FormData.LINE_BREAK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return '--' + this.getBoundary() + FormData.LINE_BREAK + contents + FormData.LINE_BREAK;
|
||||
};
|
||||
|
||||
FormData.prototype._getContentDisposition = function(value, options) {
|
||||
|
||||
var filename
|
||||
, contentDisposition
|
||||
;
|
||||
|
||||
if (typeof options.filepath === 'string') {
|
||||
// custom filepath for relative paths
|
||||
filename = path.normalize(options.filepath).replace(/\\/g, '/');
|
||||
} else if (options.filename || value.name || value.path) {
|
||||
// custom filename take precedence
|
||||
// formidable and the browser add a name property
|
||||
// fs- and request- streams have path property
|
||||
filename = path.basename(options.filename || value.name || value.path);
|
||||
} else if (value.readable && Object.prototype.hasOwnProperty.call(value, 'httpVersion')) {
|
||||
// or try http response
|
||||
filename = path.basename(value.client._httpMessage.path || '');
|
||||
}
|
||||
|
||||
if (filename) {
|
||||
contentDisposition = 'filename="' + filename + '"';
|
||||
}
|
||||
|
||||
return contentDisposition;
|
||||
};
|
||||
|
||||
FormData.prototype._getContentType = function(value, options) {
|
||||
|
||||
// use custom content-type above all
|
||||
var contentType = options.contentType;
|
||||
|
||||
// or try `name` from formidable, browser
|
||||
if (!contentType && value.name) {
|
||||
contentType = mime.lookup(value.name);
|
||||
}
|
||||
|
||||
// or try `path` from fs-, request- streams
|
||||
if (!contentType && value.path) {
|
||||
contentType = mime.lookup(value.path);
|
||||
}
|
||||
|
||||
// or if it's http-reponse
|
||||
if (!contentType && value.readable && Object.prototype.hasOwnProperty.call(value, 'httpVersion')) {
|
||||
contentType = value.headers['content-type'];
|
||||
}
|
||||
|
||||
// or guess it from the filepath or filename
|
||||
if (!contentType && (options.filepath || options.filename)) {
|
||||
contentType = mime.lookup(options.filepath || options.filename);
|
||||
}
|
||||
|
||||
// fallback to the default content type if `value` is not simple value
|
||||
if (!contentType && typeof value == 'object') {
|
||||
contentType = FormData.DEFAULT_CONTENT_TYPE;
|
||||
}
|
||||
|
||||
return contentType;
|
||||
};
|
||||
|
||||
FormData.prototype._multiPartFooter = function() {
|
||||
return function(next) {
|
||||
var footer = FormData.LINE_BREAK;
|
||||
|
||||
var lastPart = (this._streams.length === 0);
|
||||
if (lastPart) {
|
||||
footer += this._lastBoundary();
|
||||
}
|
||||
|
||||
next(footer);
|
||||
}.bind(this);
|
||||
};
|
||||
|
||||
FormData.prototype._lastBoundary = function() {
|
||||
return '--' + this.getBoundary() + '--' + FormData.LINE_BREAK;
|
||||
};
|
||||
|
||||
FormData.prototype.getHeaders = function(userHeaders) {
|
||||
var header;
|
||||
var formHeaders = {
|
||||
'content-type': 'multipart/form-data; boundary=' + this.getBoundary()
|
||||
};
|
||||
|
||||
for (header in userHeaders) {
|
||||
if (Object.prototype.hasOwnProperty.call(userHeaders, header)) {
|
||||
formHeaders[header.toLowerCase()] = userHeaders[header];
|
||||
}
|
||||
}
|
||||
|
||||
return formHeaders;
|
||||
};
|
||||
|
||||
FormData.prototype.setBoundary = function(boundary) {
|
||||
this._boundary = boundary;
|
||||
};
|
||||
|
||||
FormData.prototype.getBoundary = function() {
|
||||
if (!this._boundary) {
|
||||
this._generateBoundary();
|
||||
}
|
||||
|
||||
return this._boundary;
|
||||
};
|
||||
|
||||
FormData.prototype.getBuffer = function() {
|
||||
var dataBuffer = new Buffer.alloc(0);
|
||||
var boundary = this.getBoundary();
|
||||
|
||||
// Create the form content. Add Line breaks to the end of data.
|
||||
for (var i = 0, len = this._streams.length; i < len; i++) {
|
||||
if (typeof this._streams[i] !== 'function') {
|
||||
|
||||
// Add content to the buffer.
|
||||
if(Buffer.isBuffer(this._streams[i])) {
|
||||
dataBuffer = Buffer.concat( [dataBuffer, this._streams[i]]);
|
||||
}else {
|
||||
dataBuffer = Buffer.concat( [dataBuffer, Buffer.from(this._streams[i])]);
|
||||
}
|
||||
|
||||
// Add break after content.
|
||||
if (typeof this._streams[i] !== 'string' || this._streams[i].substring( 2, boundary.length + 2 ) !== boundary) {
|
||||
dataBuffer = Buffer.concat( [dataBuffer, Buffer.from(FormData.LINE_BREAK)] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add the footer and return the Buffer object.
|
||||
return Buffer.concat( [dataBuffer, Buffer.from(this._lastBoundary())] );
|
||||
};
|
||||
|
||||
FormData.prototype._generateBoundary = function() {
|
||||
// This generates a 50 character boundary similar to those used by Firefox.
|
||||
// They are optimized for boyer-moore parsing.
|
||||
var boundary = '--------------------------';
|
||||
for (var i = 0; i < 24; i++) {
|
||||
boundary += Math.floor(Math.random() * 10).toString(16);
|
||||
}
|
||||
|
||||
this._boundary = boundary;
|
||||
};
|
||||
|
||||
// Note: getLengthSync DOESN'T calculate streams length
|
||||
// As workaround one can calculate file size manually
|
||||
// and add it as knownLength option
|
||||
FormData.prototype.getLengthSync = function() {
|
||||
var knownLength = this._overheadLength + this._valueLength;
|
||||
|
||||
// Don't get confused, there are 3 "internal" streams for each keyval pair
|
||||
// so it basically checks if there is any value added to the form
|
||||
if (this._streams.length) {
|
||||
knownLength += this._lastBoundary().length;
|
||||
}
|
||||
|
||||
// https://github.com/form-data/form-data/issues/40
|
||||
if (!this.hasKnownLength()) {
|
||||
// Some async length retrievers are present
|
||||
// therefore synchronous length calculation is false.
|
||||
// Please use getLength(callback) to get proper length
|
||||
this._error(new Error('Cannot calculate proper length in synchronous way.'));
|
||||
}
|
||||
|
||||
return knownLength;
|
||||
};
|
||||
|
||||
// Public API to check if length of added values is known
|
||||
// https://github.com/form-data/form-data/issues/196
|
||||
// https://github.com/form-data/form-data/issues/262
|
||||
FormData.prototype.hasKnownLength = function() {
|
||||
var hasKnownLength = true;
|
||||
|
||||
if (this._valuesToMeasure.length) {
|
||||
hasKnownLength = false;
|
||||
}
|
||||
|
||||
return hasKnownLength;
|
||||
};
|
||||
|
||||
FormData.prototype.getLength = function(cb) {
|
||||
var knownLength = this._overheadLength + this._valueLength;
|
||||
|
||||
if (this._streams.length) {
|
||||
knownLength += this._lastBoundary().length;
|
||||
}
|
||||
|
||||
if (!this._valuesToMeasure.length) {
|
||||
process.nextTick(cb.bind(this, null, knownLength));
|
||||
return;
|
||||
}
|
||||
|
||||
asynckit.parallel(this._valuesToMeasure, this._lengthRetriever, function(err, values) {
|
||||
if (err) {
|
||||
cb(err);
|
||||
return;
|
||||
}
|
||||
|
||||
values.forEach(function(length) {
|
||||
knownLength += length;
|
||||
});
|
||||
|
||||
cb(null, knownLength);
|
||||
});
|
||||
};
|
||||
|
||||
FormData.prototype.submit = function(params, cb) {
|
||||
var request
|
||||
, options
|
||||
, defaults = {method: 'post'}
|
||||
;
|
||||
|
||||
// parse provided url if it's string
|
||||
// or treat it as options object
|
||||
if (typeof params == 'string') {
|
||||
|
||||
params = parseUrl(params);
|
||||
options = populate({
|
||||
port: params.port,
|
||||
path: params.pathname,
|
||||
host: params.hostname,
|
||||
protocol: params.protocol
|
||||
}, defaults);
|
||||
|
||||
// use custom params
|
||||
} else {
|
||||
|
||||
options = populate(params, defaults);
|
||||
// if no port provided use default one
|
||||
if (!options.port) {
|
||||
options.port = options.protocol == 'https:' ? 443 : 80;
|
||||
}
|
||||
}
|
||||
|
||||
// put that good code in getHeaders to some use
|
||||
options.headers = this.getHeaders(params.headers);
|
||||
|
||||
// https if specified, fallback to http in any other case
|
||||
if (options.protocol == 'https:') {
|
||||
request = https.request(options);
|
||||
} else {
|
||||
request = http.request(options);
|
||||
}
|
||||
|
||||
// get content length and fire away
|
||||
this.getLength(function(err, length) {
|
||||
if (err && err !== 'Unknown stream') {
|
||||
this._error(err);
|
||||
return;
|
||||
}
|
||||
|
||||
// add content length
|
||||
if (length) {
|
||||
request.setHeader('Content-Length', length);
|
||||
}
|
||||
|
||||
this.pipe(request);
|
||||
if (cb) {
|
||||
var onResponse;
|
||||
|
||||
var callback = function (error, responce) {
|
||||
request.removeListener('error', callback);
|
||||
request.removeListener('response', onResponse);
|
||||
|
||||
return cb.call(this, error, responce);
|
||||
};
|
||||
|
||||
onResponse = callback.bind(this, null);
|
||||
|
||||
request.on('error', callback);
|
||||
request.on('response', onResponse);
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
return request;
|
||||
};
|
||||
|
||||
FormData.prototype._error = function(err) {
|
||||
if (!this.error) {
|
||||
this.error = err;
|
||||
this.pause();
|
||||
this.emit('error', err);
|
||||
}
|
||||
};
|
||||
|
||||
FormData.prototype.toString = function () {
|
||||
return '[object FormData]';
|
||||
};
|
||||
setToStringTag(FormData, 'FormData');
|
||||
10
node_modules/jsdom/node_modules/form-data/lib/populate.js
generated
vendored
Normal file
10
node_modules/jsdom/node_modules/form-data/lib/populate.js
generated
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// populates missing values
|
||||
module.exports = function(dst, src) {
|
||||
|
||||
Object.keys(src).forEach(function(prop)
|
||||
{
|
||||
dst[prop] = dst[prop] || src[prop];
|
||||
});
|
||||
|
||||
return dst;
|
||||
};
|
||||
74
node_modules/jsdom/node_modules/form-data/package.json
generated
vendored
Normal file
74
node_modules/jsdom/node_modules/form-data/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
{
|
||||
"author": "Felix Geisendörfer <felix@debuggable.com> (http://debuggable.com/)",
|
||||
"name": "form-data",
|
||||
"description": "A library to create readable \"multipart/form-data\" streams. Can be used to submit forms and file uploads to other web applications.",
|
||||
"version": "4.0.2",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/form-data/form-data.git"
|
||||
},
|
||||
"main": "./lib/form_data",
|
||||
"browser": "./lib/browser",
|
||||
"typings": "./index.d.ts",
|
||||
"scripts": {
|
||||
"pretest": "npm run lint",
|
||||
"pretests-only": "rimraf coverage test/tmp",
|
||||
"tests-only": "istanbul cover test/run.js",
|
||||
"posttests-only": "istanbul report lcov text",
|
||||
"test": "npm run tests-only",
|
||||
"posttest": "npx npm@'>=10.2' audit --production",
|
||||
"lint": "eslint --ext=js,mjs .",
|
||||
"report": "istanbul report lcov text",
|
||||
"ci-lint": "is-node-modern 8 && npm run lint || is-node-not-modern 8",
|
||||
"ci-test": "npm run tests-only && npm run browser && npm run report",
|
||||
"predebug": "rimraf coverage test/tmp",
|
||||
"debug": "verbose=1 ./test/run.js",
|
||||
"browser": "browserify -t browserify-istanbul test/run-browser.js | obake --coverage",
|
||||
"check": "istanbul check-coverage coverage/coverage*.json",
|
||||
"files": "pkgfiles --sort=name",
|
||||
"get-version": "node -e \"console.log(require('./package.json').version)\"",
|
||||
"update-readme": "sed -i.bak 's/\\/master\\.svg/\\/v'$(npm --silent run get-version)'.svg/g' README.md",
|
||||
"restore-readme": "mv README.md.bak README.md",
|
||||
"prepublish": "in-publish && npm run update-readme || not-in-publish",
|
||||
"postpublish": "npm run restore-readme"
|
||||
},
|
||||
"pre-commit": [
|
||||
"lint",
|
||||
"ci-test",
|
||||
"check"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
},
|
||||
"dependencies": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.8",
|
||||
"es-set-tostringtag": "^2.1.0",
|
||||
"mime-types": "^2.1.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/combined-stream": "^1.0.6",
|
||||
"@types/mime-types": "^2.1.4",
|
||||
"@types/node": "^12.20.55",
|
||||
"browserify": "^13.3.0",
|
||||
"browserify-istanbul": "^2.0.0",
|
||||
"coveralls": "^3.1.1",
|
||||
"cross-spawn": "^6.0.6",
|
||||
"eslint": "^6.8.0",
|
||||
"fake": "^0.2.2",
|
||||
"far": "^0.0.7",
|
||||
"formidable": "^1.2.6",
|
||||
"in-publish": "^2.0.1",
|
||||
"is-node-modern": "^1.0.0",
|
||||
"istanbul": "^0.4.5",
|
||||
"obake": "^0.1.2",
|
||||
"pkgfiles": "^2.3.2",
|
||||
"pre-commit": "^1.2.2",
|
||||
"puppeteer": "^1.20.0",
|
||||
"request": "~2.87.0",
|
||||
"rimraf": "^2.7.1",
|
||||
"tape": "^5.9.0",
|
||||
"typescript": "^3.9.10"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
21
node_modules/jsdom/node_modules/tr46/LICENSE.md
generated
vendored
Normal file
21
node_modules/jsdom/node_modules/tr46/LICENSE.md
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sebastian Mayr
|
||||
|
||||
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.
|
||||
76
node_modules/jsdom/node_modules/tr46/README.md
generated
vendored
Normal file
76
node_modules/jsdom/node_modules/tr46/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
# tr46
|
||||
|
||||
An JavaScript implementation of [Unicode Technical Standard #46: Unicode IDNA Compatibility Processing](https://unicode.org/reports/tr46/).
|
||||
|
||||
## API
|
||||
|
||||
### `toASCII(domainName[, options])`
|
||||
|
||||
Converts a string of Unicode symbols to a case-folded Punycode string of ASCII symbols.
|
||||
|
||||
Available options:
|
||||
|
||||
* [`checkBidi`](#checkbidi)
|
||||
* [`checkHyphens`](#checkhyphens)
|
||||
* [`checkJoiners`](#checkjoiners)
|
||||
* [`ignoreInvalidPunycode`](#ignoreinvalidpunycode)
|
||||
* [`transitionalProcessing`](#transitionalprocessing)
|
||||
* [`useSTD3ASCIIRules`](#usestd3asciirules)
|
||||
* [`verifyDNSLength`](#verifydnslength)
|
||||
|
||||
### `toUnicode(domainName[, options])`
|
||||
|
||||
Converts a case-folded Punycode string of ASCII symbols to a string of Unicode symbols.
|
||||
|
||||
Available options:
|
||||
|
||||
* [`checkBidi`](#checkbidi)
|
||||
* [`checkHyphens`](#checkhyphens)
|
||||
* [`checkJoiners`](#checkjoiners)
|
||||
* [`ignoreInvalidPunycode`](#ignoreinvalidpunycode)
|
||||
* [`transitionalProcessing`](#transitionalprocessing)
|
||||
* [`useSTD3ASCIIRules`](#usestd3asciirules)
|
||||
|
||||
## Options
|
||||
|
||||
### `checkBidi`
|
||||
|
||||
Type: `boolean`
|
||||
Default value: `false`
|
||||
When set to `true`, any bi-directional text within the input will be checked for validation.
|
||||
|
||||
### `checkHyphens`
|
||||
|
||||
Type: `boolean`
|
||||
Default value: `false`
|
||||
When set to `true`, the positions of any hyphen characters within the input will be checked for validation.
|
||||
|
||||
### `checkJoiners`
|
||||
|
||||
Type: `boolean`
|
||||
Default value: `false`
|
||||
When set to `true`, any word joiner characters within the input will be checked for validation.
|
||||
|
||||
### `ignoreInvalidPunycode`
|
||||
|
||||
Type: `boolean`
|
||||
Default value: `false`
|
||||
When set to `true`, invalid Punycode strings within the input will be allowed.
|
||||
|
||||
### `transitionalProcessing`
|
||||
|
||||
Type: `boolean`
|
||||
Default value: `false`
|
||||
When set to `true`, uses [transitional (compatibility) processing](https://unicode.org/reports/tr46/#Compatibility_Processing) of the deviation characters.
|
||||
|
||||
### `useSTD3ASCIIRules`
|
||||
|
||||
Type: `boolean`
|
||||
Default value: `false`
|
||||
When set to `true`, input will be validated according to [STD3 Rules](http://unicode.org/reports/tr46/#STD3_Rules).
|
||||
|
||||
### `verifyDNSLength`
|
||||
|
||||
Type: `boolean`
|
||||
Default value: `false`
|
||||
When set to `true`, the length of each DNS label within the input will be checked for validation.
|
||||
344
node_modules/jsdom/node_modules/tr46/index.js
generated
vendored
Normal file
344
node_modules/jsdom/node_modules/tr46/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,344 @@
|
|||
"use strict";
|
||||
|
||||
const punycode = require("punycode/");
|
||||
const regexes = require("./lib/regexes.js");
|
||||
const mappingTable = require("./lib/mappingTable.json");
|
||||
const { STATUS_MAPPING } = require("./lib/statusMapping.js");
|
||||
|
||||
function containsNonASCII(str) {
|
||||
return /[^\x00-\x7F]/u.test(str);
|
||||
}
|
||||
|
||||
function findStatus(val) {
|
||||
let start = 0;
|
||||
let end = mappingTable.length - 1;
|
||||
|
||||
while (start <= end) {
|
||||
const mid = Math.floor((start + end) / 2);
|
||||
|
||||
const target = mappingTable[mid];
|
||||
const min = Array.isArray(target[0]) ? target[0][0] : target[0];
|
||||
const max = Array.isArray(target[0]) ? target[0][1] : target[0];
|
||||
|
||||
if (min <= val && max >= val) {
|
||||
return target.slice(1);
|
||||
} else if (min > val) {
|
||||
end = mid - 1;
|
||||
} else {
|
||||
start = mid + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function mapChars(domainName, { transitionalProcessing }) {
|
||||
let processed = "";
|
||||
|
||||
for (const ch of domainName) {
|
||||
const [status, mapping] = findStatus(ch.codePointAt(0));
|
||||
|
||||
switch (status) {
|
||||
case STATUS_MAPPING.disallowed:
|
||||
processed += ch;
|
||||
break;
|
||||
case STATUS_MAPPING.ignored:
|
||||
break;
|
||||
case STATUS_MAPPING.mapped:
|
||||
if (transitionalProcessing && ch === "ẞ") {
|
||||
processed += "ss";
|
||||
} else {
|
||||
processed += mapping;
|
||||
}
|
||||
break;
|
||||
case STATUS_MAPPING.deviation:
|
||||
if (transitionalProcessing) {
|
||||
processed += mapping;
|
||||
} else {
|
||||
processed += ch;
|
||||
}
|
||||
break;
|
||||
case STATUS_MAPPING.valid:
|
||||
processed += ch;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
||||
function validateLabel(label, {
|
||||
checkHyphens,
|
||||
checkBidi,
|
||||
checkJoiners,
|
||||
transitionalProcessing,
|
||||
useSTD3ASCIIRules,
|
||||
isBidi
|
||||
}) {
|
||||
// "must be satisfied for a non-empty label"
|
||||
if (label.length === 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// "1. The label must be in Unicode Normalization Form NFC."
|
||||
if (label.normalize("NFC") !== label) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const codePoints = Array.from(label);
|
||||
|
||||
// "2. If CheckHyphens, the label must not contain a U+002D HYPHEN-MINUS character in both the
|
||||
// third and fourth positions."
|
||||
//
|
||||
// "3. If CheckHyphens, the label must neither begin nor end with a U+002D HYPHEN-MINUS character."
|
||||
if (checkHyphens) {
|
||||
if ((codePoints[2] === "-" && codePoints[3] === "-") ||
|
||||
(label.startsWith("-") || label.endsWith("-"))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// "4. If not CheckHyphens, the label must not begin with “xn--”."
|
||||
if (!checkHyphens) {
|
||||
if (label.startsWith("xn--")) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// "5. The label must not contain a U+002E ( . ) FULL STOP."
|
||||
if (label.includes(".")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// "6. The label must not begin with a combining mark, that is: General_Category=Mark."
|
||||
if (regexes.combiningMarks.test(codePoints[0])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// "7. Each code point in the label must only have certain Status values according to Section 5"
|
||||
for (const ch of codePoints) {
|
||||
const codePoint = ch.codePointAt(0);
|
||||
const [status] = findStatus(codePoint);
|
||||
if (transitionalProcessing) {
|
||||
// "For Transitional Processing (deprecated), each value must be valid."
|
||||
if (status !== STATUS_MAPPING.valid) {
|
||||
return false;
|
||||
}
|
||||
} else if (status !== STATUS_MAPPING.valid && status !== STATUS_MAPPING.deviation) {
|
||||
// "For Nontransitional Processing, each value must be either valid or deviation."
|
||||
return false;
|
||||
}
|
||||
// "In addition, if UseSTD3ASCIIRules=true and the code point is an ASCII code point (U+0000..U+007F), then it must
|
||||
// be a lowercase letter (a-z), a digit (0-9), or a hyphen-minus (U+002D). (Note: This excludes uppercase ASCII
|
||||
// A-Z which are mapped in UTS #46 and disallowed in IDNA2008.)"
|
||||
if (useSTD3ASCIIRules && codePoint <= 0x7F) {
|
||||
if (!/^[a-z][0-9]-$/u.test(ch)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// "8. If CheckJoiners, the label must satisify the ContextJ rules"
|
||||
// https://tools.ietf.org/html/rfc5892#appendix-A
|
||||
if (checkJoiners) {
|
||||
let last = 0;
|
||||
for (const [i, ch] of codePoints.entries()) {
|
||||
if (ch === "\u200C" || ch === "\u200D") {
|
||||
if (i > 0) {
|
||||
if (regexes.combiningClassVirama.test(codePoints[i - 1])) {
|
||||
continue;
|
||||
}
|
||||
if (ch === "\u200C") {
|
||||
// TODO: make this more efficient
|
||||
const next = codePoints.indexOf("\u200C", i + 1);
|
||||
const test = next < 0 ? codePoints.slice(last) : codePoints.slice(last, next);
|
||||
if (regexes.validZWNJ.test(test.join(""))) {
|
||||
last = i + 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// "9. If CheckBidi, and if the domain name is a Bidi domain name, then the label must satisfy..."
|
||||
// https://tools.ietf.org/html/rfc5893#section-2
|
||||
if (checkBidi && isBidi) {
|
||||
let rtl;
|
||||
|
||||
// 1
|
||||
if (regexes.bidiS1LTR.test(codePoints[0])) {
|
||||
rtl = false;
|
||||
} else if (regexes.bidiS1RTL.test(codePoints[0])) {
|
||||
rtl = true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rtl) {
|
||||
// 2-4
|
||||
if (!regexes.bidiS2.test(label) ||
|
||||
!regexes.bidiS3.test(label) ||
|
||||
(regexes.bidiS4EN.test(label) && regexes.bidiS4AN.test(label))) {
|
||||
return false;
|
||||
}
|
||||
} else if (!regexes.bidiS5.test(label) ||
|
||||
!regexes.bidiS6.test(label)) { // 5-6
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function isBidiDomain(labels) {
|
||||
const domain = labels.map(label => {
|
||||
if (label.startsWith("xn--")) {
|
||||
try {
|
||||
return punycode.decode(label.substring(4));
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
return label;
|
||||
}).join(".");
|
||||
return regexes.bidiDomain.test(domain);
|
||||
}
|
||||
|
||||
function processing(domainName, options) {
|
||||
// 1. Map.
|
||||
let string = mapChars(domainName, options);
|
||||
|
||||
// 2. Normalize.
|
||||
string = string.normalize("NFC");
|
||||
|
||||
// 3. Break.
|
||||
const labels = string.split(".");
|
||||
const isBidi = isBidiDomain(labels);
|
||||
|
||||
// 4. Convert/Validate.
|
||||
let error = false;
|
||||
for (const [i, origLabel] of labels.entries()) {
|
||||
let label = origLabel;
|
||||
let transitionalProcessingForThisLabel = options.transitionalProcessing;
|
||||
if (label.startsWith("xn--")) {
|
||||
if (containsNonASCII(label)) {
|
||||
error = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
label = punycode.decode(label.substring(4));
|
||||
} catch {
|
||||
if (!options.ignoreInvalidPunycode) {
|
||||
error = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
labels[i] = label;
|
||||
|
||||
if (label === "" || !containsNonASCII(label)) {
|
||||
error = true;
|
||||
}
|
||||
|
||||
transitionalProcessingForThisLabel = false;
|
||||
}
|
||||
|
||||
// No need to validate if we already know there is an error.
|
||||
if (error) {
|
||||
continue;
|
||||
}
|
||||
const validation = validateLabel(label, {
|
||||
...options,
|
||||
transitionalProcessing: transitionalProcessingForThisLabel,
|
||||
isBidi
|
||||
});
|
||||
if (!validation) {
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
string: labels.join("."),
|
||||
error
|
||||
};
|
||||
}
|
||||
|
||||
function toASCII(domainName, {
|
||||
checkHyphens = false,
|
||||
checkBidi = false,
|
||||
checkJoiners = false,
|
||||
useSTD3ASCIIRules = false,
|
||||
verifyDNSLength = false,
|
||||
transitionalProcessing = false,
|
||||
ignoreInvalidPunycode = false
|
||||
} = {}) {
|
||||
const result = processing(domainName, {
|
||||
checkHyphens,
|
||||
checkBidi,
|
||||
checkJoiners,
|
||||
useSTD3ASCIIRules,
|
||||
transitionalProcessing,
|
||||
ignoreInvalidPunycode
|
||||
});
|
||||
let labels = result.string.split(".");
|
||||
labels = labels.map(l => {
|
||||
if (containsNonASCII(l)) {
|
||||
try {
|
||||
return `xn--${punycode.encode(l)}`;
|
||||
} catch {
|
||||
result.error = true;
|
||||
}
|
||||
}
|
||||
return l;
|
||||
});
|
||||
|
||||
if (verifyDNSLength) {
|
||||
const total = labels.join(".").length;
|
||||
if (total > 253 || total === 0) {
|
||||
result.error = true;
|
||||
}
|
||||
|
||||
for (let i = 0; i < labels.length; ++i) {
|
||||
if (labels[i].length > 63 || labels[i].length === 0) {
|
||||
result.error = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result.error) {
|
||||
return null;
|
||||
}
|
||||
return labels.join(".");
|
||||
}
|
||||
|
||||
function toUnicode(domainName, {
|
||||
checkHyphens = false,
|
||||
checkBidi = false,
|
||||
checkJoiners = false,
|
||||
useSTD3ASCIIRules = false,
|
||||
transitionalProcessing = false,
|
||||
ignoreInvalidPunycode = false
|
||||
} = {}) {
|
||||
const result = processing(domainName, {
|
||||
checkHyphens,
|
||||
checkBidi,
|
||||
checkJoiners,
|
||||
useSTD3ASCIIRules,
|
||||
transitionalProcessing,
|
||||
ignoreInvalidPunycode
|
||||
});
|
||||
|
||||
return {
|
||||
domain: result.string,
|
||||
error: result.error
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
toASCII,
|
||||
toUnicode
|
||||
};
|
||||
1
node_modules/jsdom/node_modules/tr46/lib/mappingTable.json
generated
vendored
Normal file
1
node_modules/jsdom/node_modules/tr46/lib/mappingTable.json
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
29
node_modules/jsdom/node_modules/tr46/lib/regexes.js
generated
vendored
Normal file
29
node_modules/jsdom/node_modules/tr46/lib/regexes.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
9
node_modules/jsdom/node_modules/tr46/lib/statusMapping.js
generated
vendored
Normal file
9
node_modules/jsdom/node_modules/tr46/lib/statusMapping.js
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
"use strict";
|
||||
|
||||
module.exports.STATUS_MAPPING = {
|
||||
mapped: 1,
|
||||
valid: 2,
|
||||
disallowed: 3,
|
||||
deviation: 6,
|
||||
ignored: 7
|
||||
};
|
||||
44
node_modules/jsdom/node_modules/tr46/package.json
generated
vendored
Normal file
44
node_modules/jsdom/node_modules/tr46/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
"name": "tr46",
|
||||
"version": "5.1.0",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"description": "An implementation of the Unicode UTS #46: Unicode IDNA Compatibility Processing",
|
||||
"main": "index.js",
|
||||
"files": [
|
||||
"index.js",
|
||||
"lib/"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "node --test",
|
||||
"lint": "eslint",
|
||||
"pretest": "node scripts/getLatestTests.js",
|
||||
"prepublish": "node scripts/generateMappingTable.js && node scripts/generateRegexes.js"
|
||||
},
|
||||
"repository": "https://github.com/jsdom/tr46",
|
||||
"keywords": [
|
||||
"unicode",
|
||||
"tr46",
|
||||
"uts46",
|
||||
"punycode",
|
||||
"url",
|
||||
"whatwg"
|
||||
],
|
||||
"author": "Sebastian Mayr <npm@smayr.name>",
|
||||
"contributors": [
|
||||
"Timothy Gu <timothygu99@gmail.com>"
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"punycode": "^2.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@domenic/eslint-config": "^4.0.1",
|
||||
"@unicode/unicode-16.0.0": "^1.6.5",
|
||||
"eslint": "^9.22.0",
|
||||
"globals": "^16.0.0",
|
||||
"regenerate": "^1.4.2"
|
||||
},
|
||||
"unicodeVersion": "16.0.0"
|
||||
}
|
||||
12
node_modules/jsdom/node_modules/webidl-conversions/LICENSE.md
generated
vendored
Normal file
12
node_modules/jsdom/node_modules/webidl-conversions/LICENSE.md
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# The BSD 2-Clause License
|
||||
|
||||
Copyright (c) 2014, Domenic Denicola
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
99
node_modules/jsdom/node_modules/webidl-conversions/README.md
generated
vendored
Normal file
99
node_modules/jsdom/node_modules/webidl-conversions/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
# Web IDL Type Conversions on JavaScript Values
|
||||
|
||||
This package implements, in JavaScript, the algorithms to convert a given JavaScript value according to a given [Web IDL](http://heycam.github.io/webidl/) [type](http://heycam.github.io/webidl/#idl-types).
|
||||
|
||||
The goal is that you should be able to write code like
|
||||
|
||||
```js
|
||||
"use strict";
|
||||
const conversions = require("webidl-conversions");
|
||||
|
||||
function doStuff(x, y) {
|
||||
x = conversions["boolean"](x);
|
||||
y = conversions["unsigned long"](y);
|
||||
// actual algorithm code here
|
||||
}
|
||||
```
|
||||
|
||||
and your function `doStuff` will behave the same as a Web IDL operation declared as
|
||||
|
||||
```webidl
|
||||
undefined doStuff(boolean x, unsigned long y);
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
This package's main module's default export is an object with a variety of methods, each corresponding to a different Web IDL type. Each method, when invoked on a JavaScript value, will give back the new JavaScript value that results after passing through the Web IDL conversion rules. (See below for more details on what that means.) Alternately, the method could throw an error, if the Web IDL algorithm is specified to do so: for example `conversions["float"](NaN)` [will throw a `TypeError`](http://heycam.github.io/webidl/#es-float).
|
||||
|
||||
Each method also accepts a second, optional, parameter for miscellaneous options. For conversion methods that throw errors, a string option `{ context }` may be provided to provide more information in the error message. (For example, `conversions["float"](NaN, { context: "Argument 1 of Interface's operation" })` will throw an error with message `"Argument 1 of Interface's operation is not a finite floating-point value."`)
|
||||
|
||||
If we are dealing with multiple JavaScript realms (such as those created using Node.js' [vm](https://nodejs.org/api/vm.html) module or the HTML `iframe` element), and exceptions from another realm need to be thrown, one can supply an object option `globals` containing the following properties:
|
||||
|
||||
```js
|
||||
{
|
||||
globals: {
|
||||
Number,
|
||||
String,
|
||||
TypeError
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Those specific functions will be used when throwing exceptions.
|
||||
|
||||
Specific conversions may also accept other options, the details of which can be found below.
|
||||
|
||||
## Conversions implemented
|
||||
|
||||
Conversions for all of the basic types from the Web IDL specification are implemented:
|
||||
|
||||
- [`any`](https://heycam.github.io/webidl/#es-any)
|
||||
- [`undefined`](https://heycam.github.io/webidl/#es-undefined)
|
||||
- [`boolean`](https://heycam.github.io/webidl/#es-boolean)
|
||||
- [Integer types](https://heycam.github.io/webidl/#es-integer-types), which can additionally be provided the boolean options `{ clamp, enforceRange }` as a second parameter
|
||||
- [`float`](https://heycam.github.io/webidl/#es-float), [`unrestricted float`](https://heycam.github.io/webidl/#es-unrestricted-float)
|
||||
- [`double`](https://heycam.github.io/webidl/#es-double), [`unrestricted double`](https://heycam.github.io/webidl/#es-unrestricted-double)
|
||||
- [`DOMString`](https://heycam.github.io/webidl/#es-DOMString), which can additionally be provided the boolean option `{ treatNullAsEmptyString }` as a second parameter
|
||||
- [`ByteString`](https://heycam.github.io/webidl/#es-ByteString), [`USVString`](https://heycam.github.io/webidl/#es-USVString)
|
||||
- [`object`](https://heycam.github.io/webidl/#es-object)
|
||||
- [Buffer source types](https://heycam.github.io/webidl/#es-buffer-source-types), which can additionally be provided with the boolean option `{ allowShared }` as a second parameter
|
||||
|
||||
Additionally, for convenience, the following derived type definitions are implemented:
|
||||
|
||||
- [`ArrayBufferView`](https://heycam.github.io/webidl/#ArrayBufferView), which can additionally be provided with the boolean option `{ allowShared }` as a second parameter
|
||||
- [`BufferSource`](https://heycam.github.io/webidl/#BufferSource)
|
||||
- [`DOMTimeStamp`](https://heycam.github.io/webidl/#DOMTimeStamp)
|
||||
|
||||
Derived types, such as nullable types, promise types, sequences, records, etc. are not handled by this library. You may wish to investigate the [webidl2js](https://github.com/jsdom/webidl2js) project.
|
||||
|
||||
### A note on the `long long` types
|
||||
|
||||
The `long long` and `unsigned long long` Web IDL types can hold values that cannot be stored in JavaScript numbers. Conversions are still accurate as we make use of BigInt in the conversion process, but in the case of `unsigned long long` we simply cannot represent some possible output values in JavaScript. For example, converting the JavaScript number `-1` to a Web IDL `unsigned long long` is supposed to produce the Web IDL value `18446744073709551615`. Since we are representing our Web IDL values in JavaScript, we can't represent `18446744073709551615`, so we instead the best we could do is `18446744073709551616` as the output.
|
||||
|
||||
To mitigate this, we could return the raw BigInt value from the conversion function, but right now it is not implemented. If your use case requires such precision, [file an issue](https://github.com/jsdom/webidl-conversions/issues/new).
|
||||
|
||||
On the other hand, `long long` conversion is always accurate, since the input value can never be more precise than the output value.
|
||||
|
||||
### A note on `BufferSource` types
|
||||
|
||||
All of the `BufferSource` types will throw when the relevant `ArrayBuffer` has been detached. This technically is not part of the [specified conversion algorithm](https://heycam.github.io/webidl/#es-buffer-source-types), but instead part of the [getting a reference/getting a copy](https://heycam.github.io/webidl/#ref-for-dfn-get-buffer-source-reference%E2%91%A0) algorithms. We've consolidated them here for convenience and ease of implementation, but if there is a need to separate them in the future, please open an issue so we can investigate.
|
||||
|
||||
## Background
|
||||
|
||||
What's actually going on here, conceptually, is pretty weird. Let's try to explain.
|
||||
|
||||
Web IDL, as part of its madness-inducing design, has its own type system. When people write algorithms in web platform specs, they usually operate on Web IDL values, i.e. instances of Web IDL types. For example, if they were specifying the algorithm for our `doStuff` operation above, they would treat `x` as a Web IDL value of [Web IDL type `boolean`](http://heycam.github.io/webidl/#idl-boolean). Crucially, they would _not_ treat `x` as a JavaScript variable whose value is either the JavaScript `true` or `false`. They're instead working in a different type system altogether, with its own rules.
|
||||
|
||||
Separately from its type system, Web IDL defines a ["binding"](http://heycam.github.io/webidl/#ecmascript-binding) of the type system into JavaScript. This contains rules like: when you pass a JavaScript value to the JavaScript method that manifests a given Web IDL operation, how does that get converted into a Web IDL value? For example, a JavaScript `true` passed in the position of a Web IDL `boolean` argument becomes a Web IDL `true`. But, a JavaScript `true` passed in the position of a [Web IDL `unsigned long`](http://heycam.github.io/webidl/#idl-unsigned-long) becomes a Web IDL `1`. And so on.
|
||||
|
||||
Finally, we have the actual implementation code. This is usually C++, although these days [some smart people are using Rust](https://github.com/servo/servo). The implementation, of course, has its own type system. So when they implement the Web IDL algorithms, they don't actually use Web IDL values, since those aren't "real" outside of specs. Instead, implementations apply the Web IDL binding rules in such a way as to convert incoming JavaScript values into C++ values. For example, if code in the browser called `doStuff(true, true)`, then the implementation code would eventually receive a C++ `bool` containing `true` and a C++ `uint32_t` containing `1`.
|
||||
|
||||
The upside of all this is that implementations can abstract all the conversion logic away, letting Web IDL handle it, and focus on implementing the relevant methods in C++ with values of the correct type already provided. That is payoff of Web IDL, in a nutshell.
|
||||
|
||||
And getting to that payoff is the goal of _this_ project—but for JavaScript implementations, instead of C++ ones. That is, this library is designed to make it easier for JavaScript developers to write functions that behave like a given Web IDL operation. So conceptually, the conversion pipeline, which in its general form is JavaScript values ↦ Web IDL values ↦ implementation-language values, in this case becomes JavaScript values ↦ Web IDL values ↦ JavaScript values. And that intermediate step is where all the logic is performed: a JavaScript `true` becomes a Web IDL `1` in an unsigned long context, which then becomes a JavaScript `1`.
|
||||
|
||||
## Don't use this
|
||||
|
||||
Seriously, why would you ever use this? You really shouldn't. Web IDL is … strange, and you shouldn't be emulating its semantics. If you're looking for a generic argument-processing library, you should find one with better rules than those from Web IDL. In general, your JavaScript should not be trying to become more like Web IDL; if anything, we should fix Web IDL to make it more like JavaScript.
|
||||
|
||||
The _only_ people who should use this are those trying to create faithful implementations (or polyfills) of web platform interfaces defined in Web IDL. Its main consumer is the [jsdom](https://github.com/jsdom/jsdom) project.
|
||||
450
node_modules/jsdom/node_modules/webidl-conversions/lib/index.js
generated
vendored
Normal file
450
node_modules/jsdom/node_modules/webidl-conversions/lib/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,450 @@
|
|||
"use strict";
|
||||
|
||||
function makeException(ErrorType, message, options) {
|
||||
if (options.globals) {
|
||||
ErrorType = options.globals[ErrorType.name];
|
||||
}
|
||||
return new ErrorType(`${options.context ? options.context : "Value"} ${message}.`);
|
||||
}
|
||||
|
||||
function toNumber(value, options) {
|
||||
if (typeof value === "bigint") {
|
||||
throw makeException(TypeError, "is a BigInt which cannot be converted to a number", options);
|
||||
}
|
||||
if (!options.globals) {
|
||||
return Number(value);
|
||||
}
|
||||
return options.globals.Number(value);
|
||||
}
|
||||
|
||||
// Round x to the nearest integer, choosing the even integer if it lies halfway between two.
|
||||
function evenRound(x) {
|
||||
// There are four cases for numbers with fractional part being .5:
|
||||
//
|
||||
// case | x | floor(x) | round(x) | expected | x <> 0 | x % 1 | x & 1 | example
|
||||
// 1 | 2n + 0.5 | 2n | 2n + 1 | 2n | > | 0.5 | 0 | 0.5 -> 0
|
||||
// 2 | 2n + 1.5 | 2n + 1 | 2n + 2 | 2n + 2 | > | 0.5 | 1 | 1.5 -> 2
|
||||
// 3 | -2n - 0.5 | -2n - 1 | -2n | -2n | < | -0.5 | 0 | -0.5 -> 0
|
||||
// 4 | -2n - 1.5 | -2n - 2 | -2n - 1 | -2n - 2 | < | -0.5 | 1 | -1.5 -> -2
|
||||
// (where n is a non-negative integer)
|
||||
//
|
||||
// Branch here for cases 1 and 4
|
||||
if ((x > 0 && (x % 1) === +0.5 && (x & 1) === 0) ||
|
||||
(x < 0 && (x % 1) === -0.5 && (x & 1) === 1)) {
|
||||
return censorNegativeZero(Math.floor(x));
|
||||
}
|
||||
|
||||
return censorNegativeZero(Math.round(x));
|
||||
}
|
||||
|
||||
function integerPart(n) {
|
||||
return censorNegativeZero(Math.trunc(n));
|
||||
}
|
||||
|
||||
function sign(x) {
|
||||
return x < 0 ? -1 : 1;
|
||||
}
|
||||
|
||||
function modulo(x, y) {
|
||||
// https://tc39.github.io/ecma262/#eqn-modulo
|
||||
// Note that http://stackoverflow.com/a/4467559/3191 does NOT work for large modulos
|
||||
const signMightNotMatch = x % y;
|
||||
if (sign(y) !== sign(signMightNotMatch)) {
|
||||
return signMightNotMatch + y;
|
||||
}
|
||||
return signMightNotMatch;
|
||||
}
|
||||
|
||||
function censorNegativeZero(x) {
|
||||
return x === 0 ? 0 : x;
|
||||
}
|
||||
|
||||
function createIntegerConversion(bitLength, { unsigned }) {
|
||||
let lowerBound, upperBound;
|
||||
if (unsigned) {
|
||||
lowerBound = 0;
|
||||
upperBound = 2 ** bitLength - 1;
|
||||
} else {
|
||||
lowerBound = -(2 ** (bitLength - 1));
|
||||
upperBound = 2 ** (bitLength - 1) - 1;
|
||||
}
|
||||
|
||||
const twoToTheBitLength = 2 ** bitLength;
|
||||
const twoToOneLessThanTheBitLength = 2 ** (bitLength - 1);
|
||||
|
||||
return (value, options = {}) => {
|
||||
let x = toNumber(value, options);
|
||||
x = censorNegativeZero(x);
|
||||
|
||||
if (options.enforceRange) {
|
||||
if (!Number.isFinite(x)) {
|
||||
throw makeException(TypeError, "is not a finite number", options);
|
||||
}
|
||||
|
||||
x = integerPart(x);
|
||||
|
||||
if (x < lowerBound || x > upperBound) {
|
||||
throw makeException(
|
||||
TypeError,
|
||||
`is outside the accepted range of ${lowerBound} to ${upperBound}, inclusive`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
if (!Number.isNaN(x) && options.clamp) {
|
||||
x = Math.min(Math.max(x, lowerBound), upperBound);
|
||||
x = evenRound(x);
|
||||
return x;
|
||||
}
|
||||
|
||||
if (!Number.isFinite(x) || x === 0) {
|
||||
return 0;
|
||||
}
|
||||
x = integerPart(x);
|
||||
|
||||
// Math.pow(2, 64) is not accurately representable in JavaScript, so try to avoid these per-spec operations if
|
||||
// possible. Hopefully it's an optimization for the non-64-bitLength cases too.
|
||||
if (x >= lowerBound && x <= upperBound) {
|
||||
return x;
|
||||
}
|
||||
|
||||
// These will not work great for bitLength of 64, but oh well. See the README for more details.
|
||||
x = modulo(x, twoToTheBitLength);
|
||||
if (!unsigned && x >= twoToOneLessThanTheBitLength) {
|
||||
return x - twoToTheBitLength;
|
||||
}
|
||||
return x;
|
||||
};
|
||||
}
|
||||
|
||||
function createLongLongConversion(bitLength, { unsigned }) {
|
||||
const upperBound = Number.MAX_SAFE_INTEGER;
|
||||
const lowerBound = unsigned ? 0 : Number.MIN_SAFE_INTEGER;
|
||||
const asBigIntN = unsigned ? BigInt.asUintN : BigInt.asIntN;
|
||||
|
||||
return (value, options = {}) => {
|
||||
let x = toNumber(value, options);
|
||||
x = censorNegativeZero(x);
|
||||
|
||||
if (options.enforceRange) {
|
||||
if (!Number.isFinite(x)) {
|
||||
throw makeException(TypeError, "is not a finite number", options);
|
||||
}
|
||||
|
||||
x = integerPart(x);
|
||||
|
||||
if (x < lowerBound || x > upperBound) {
|
||||
throw makeException(
|
||||
TypeError,
|
||||
`is outside the accepted range of ${lowerBound} to ${upperBound}, inclusive`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
if (!Number.isNaN(x) && options.clamp) {
|
||||
x = Math.min(Math.max(x, lowerBound), upperBound);
|
||||
x = evenRound(x);
|
||||
return x;
|
||||
}
|
||||
|
||||
if (!Number.isFinite(x) || x === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
let xBigInt = BigInt(integerPart(x));
|
||||
xBigInt = asBigIntN(bitLength, xBigInt);
|
||||
return Number(xBigInt);
|
||||
};
|
||||
}
|
||||
|
||||
exports.any = value => {
|
||||
return value;
|
||||
};
|
||||
|
||||
exports.undefined = () => {
|
||||
return undefined;
|
||||
};
|
||||
|
||||
exports.boolean = value => {
|
||||
return Boolean(value);
|
||||
};
|
||||
|
||||
exports.byte = createIntegerConversion(8, { unsigned: false });
|
||||
exports.octet = createIntegerConversion(8, { unsigned: true });
|
||||
|
||||
exports.short = createIntegerConversion(16, { unsigned: false });
|
||||
exports["unsigned short"] = createIntegerConversion(16, { unsigned: true });
|
||||
|
||||
exports.long = createIntegerConversion(32, { unsigned: false });
|
||||
exports["unsigned long"] = createIntegerConversion(32, { unsigned: true });
|
||||
|
||||
exports["long long"] = createLongLongConversion(64, { unsigned: false });
|
||||
exports["unsigned long long"] = createLongLongConversion(64, { unsigned: true });
|
||||
|
||||
exports.double = (value, options = {}) => {
|
||||
const x = toNumber(value, options);
|
||||
|
||||
if (!Number.isFinite(x)) {
|
||||
throw makeException(TypeError, "is not a finite floating-point value", options);
|
||||
}
|
||||
|
||||
return x;
|
||||
};
|
||||
|
||||
exports["unrestricted double"] = (value, options = {}) => {
|
||||
const x = toNumber(value, options);
|
||||
|
||||
return x;
|
||||
};
|
||||
|
||||
exports.float = (value, options = {}) => {
|
||||
const x = toNumber(value, options);
|
||||
|
||||
if (!Number.isFinite(x)) {
|
||||
throw makeException(TypeError, "is not a finite floating-point value", options);
|
||||
}
|
||||
|
||||
if (Object.is(x, -0)) {
|
||||
return x;
|
||||
}
|
||||
|
||||
const y = Math.fround(x);
|
||||
|
||||
if (!Number.isFinite(y)) {
|
||||
throw makeException(TypeError, "is outside the range of a single-precision floating-point value", options);
|
||||
}
|
||||
|
||||
return y;
|
||||
};
|
||||
|
||||
exports["unrestricted float"] = (value, options = {}) => {
|
||||
const x = toNumber(value, options);
|
||||
|
||||
if (isNaN(x)) {
|
||||
return x;
|
||||
}
|
||||
|
||||
if (Object.is(x, -0)) {
|
||||
return x;
|
||||
}
|
||||
|
||||
return Math.fround(x);
|
||||
};
|
||||
|
||||
exports.DOMString = (value, options = {}) => {
|
||||
if (options.treatNullAsEmptyString && value === null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (typeof value === "symbol") {
|
||||
throw makeException(TypeError, "is a symbol, which cannot be converted to a string", options);
|
||||
}
|
||||
|
||||
const StringCtor = options.globals ? options.globals.String : String;
|
||||
return StringCtor(value);
|
||||
};
|
||||
|
||||
exports.ByteString = (value, options = {}) => {
|
||||
const x = exports.DOMString(value, options);
|
||||
let c;
|
||||
for (let i = 0; (c = x.codePointAt(i)) !== undefined; ++i) {
|
||||
if (c > 255) {
|
||||
throw makeException(TypeError, "is not a valid ByteString", options);
|
||||
}
|
||||
}
|
||||
|
||||
return x;
|
||||
};
|
||||
|
||||
exports.USVString = (value, options = {}) => {
|
||||
const S = exports.DOMString(value, options);
|
||||
const n = S.length;
|
||||
const U = [];
|
||||
for (let i = 0; i < n; ++i) {
|
||||
const c = S.charCodeAt(i);
|
||||
if (c < 0xD800 || c > 0xDFFF) {
|
||||
U.push(String.fromCodePoint(c));
|
||||
} else if (0xDC00 <= c && c <= 0xDFFF) {
|
||||
U.push(String.fromCodePoint(0xFFFD));
|
||||
} else if (i === n - 1) {
|
||||
U.push(String.fromCodePoint(0xFFFD));
|
||||
} else {
|
||||
const d = S.charCodeAt(i + 1);
|
||||
if (0xDC00 <= d && d <= 0xDFFF) {
|
||||
const a = c & 0x3FF;
|
||||
const b = d & 0x3FF;
|
||||
U.push(String.fromCodePoint((2 << 15) + ((2 << 9) * a) + b));
|
||||
++i;
|
||||
} else {
|
||||
U.push(String.fromCodePoint(0xFFFD));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return U.join("");
|
||||
};
|
||||
|
||||
exports.object = (value, options = {}) => {
|
||||
if (value === null || (typeof value !== "object" && typeof value !== "function")) {
|
||||
throw makeException(TypeError, "is not an object", options);
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
const abByteLengthGetter =
|
||||
Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get;
|
||||
const sabByteLengthGetter =
|
||||
typeof SharedArrayBuffer === "function" ?
|
||||
Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, "byteLength").get :
|
||||
null;
|
||||
|
||||
function isNonSharedArrayBuffer(value) {
|
||||
try {
|
||||
// This will throw on SharedArrayBuffers, but not detached ArrayBuffers.
|
||||
// (The spec says it should throw, but the spec conflicts with implementations: https://github.com/tc39/ecma262/issues/678)
|
||||
abByteLengthGetter.call(value);
|
||||
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function isSharedArrayBuffer(value) {
|
||||
try {
|
||||
sabByteLengthGetter.call(value);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function isArrayBufferDetached(value) {
|
||||
try {
|
||||
// eslint-disable-next-line no-new
|
||||
new Uint8Array(value);
|
||||
return false;
|
||||
} catch {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
exports.ArrayBuffer = (value, options = {}) => {
|
||||
if (!isNonSharedArrayBuffer(value)) {
|
||||
if (options.allowShared && !isSharedArrayBuffer(value)) {
|
||||
throw makeException(TypeError, "is not an ArrayBuffer or SharedArrayBuffer", options);
|
||||
}
|
||||
throw makeException(TypeError, "is not an ArrayBuffer", options);
|
||||
}
|
||||
if (isArrayBufferDetached(value)) {
|
||||
throw makeException(TypeError, "is a detached ArrayBuffer", options);
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
const dvByteLengthGetter =
|
||||
Object.getOwnPropertyDescriptor(DataView.prototype, "byteLength").get;
|
||||
exports.DataView = (value, options = {}) => {
|
||||
try {
|
||||
dvByteLengthGetter.call(value);
|
||||
} catch (e) {
|
||||
throw makeException(TypeError, "is not a DataView", options);
|
||||
}
|
||||
|
||||
if (!options.allowShared && isSharedArrayBuffer(value.buffer)) {
|
||||
throw makeException(TypeError, "is backed by a SharedArrayBuffer, which is not allowed", options);
|
||||
}
|
||||
if (isArrayBufferDetached(value.buffer)) {
|
||||
throw makeException(TypeError, "is backed by a detached ArrayBuffer", options);
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
// Returns the unforgeable `TypedArray` constructor name or `undefined`,
|
||||
// if the `this` value isn't a valid `TypedArray` object.
|
||||
//
|
||||
// https://tc39.es/ecma262/#sec-get-%typedarray%.prototype-@@tostringtag
|
||||
const typedArrayNameGetter = Object.getOwnPropertyDescriptor(
|
||||
Object.getPrototypeOf(Uint8Array).prototype,
|
||||
Symbol.toStringTag
|
||||
).get;
|
||||
[
|
||||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Uint8Array,
|
||||
Uint16Array,
|
||||
Uint32Array,
|
||||
Uint8ClampedArray,
|
||||
Float32Array,
|
||||
Float64Array
|
||||
].forEach(func => {
|
||||
const { name } = func;
|
||||
const article = /^[AEIOU]/u.test(name) ? "an" : "a";
|
||||
exports[name] = (value, options = {}) => {
|
||||
if (!ArrayBuffer.isView(value) || typedArrayNameGetter.call(value) !== name) {
|
||||
throw makeException(TypeError, `is not ${article} ${name} object`, options);
|
||||
}
|
||||
if (!options.allowShared && isSharedArrayBuffer(value.buffer)) {
|
||||
throw makeException(TypeError, "is a view on a SharedArrayBuffer, which is not allowed", options);
|
||||
}
|
||||
if (isArrayBufferDetached(value.buffer)) {
|
||||
throw makeException(TypeError, "is a view on a detached ArrayBuffer", options);
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
});
|
||||
|
||||
// Common definitions
|
||||
|
||||
exports.ArrayBufferView = (value, options = {}) => {
|
||||
if (!ArrayBuffer.isView(value)) {
|
||||
throw makeException(TypeError, "is not a view on an ArrayBuffer or SharedArrayBuffer", options);
|
||||
}
|
||||
|
||||
if (!options.allowShared && isSharedArrayBuffer(value.buffer)) {
|
||||
throw makeException(TypeError, "is a view on a SharedArrayBuffer, which is not allowed", options);
|
||||
}
|
||||
|
||||
if (isArrayBufferDetached(value.buffer)) {
|
||||
throw makeException(TypeError, "is a view on a detached ArrayBuffer", options);
|
||||
}
|
||||
return value;
|
||||
};
|
||||
|
||||
exports.BufferSource = (value, options = {}) => {
|
||||
if (ArrayBuffer.isView(value)) {
|
||||
if (!options.allowShared && isSharedArrayBuffer(value.buffer)) {
|
||||
throw makeException(TypeError, "is a view on a SharedArrayBuffer, which is not allowed", options);
|
||||
}
|
||||
|
||||
if (isArrayBufferDetached(value.buffer)) {
|
||||
throw makeException(TypeError, "is a view on a detached ArrayBuffer", options);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
if (!options.allowShared && !isNonSharedArrayBuffer(value)) {
|
||||
throw makeException(TypeError, "is not an ArrayBuffer or a view on one", options);
|
||||
}
|
||||
if (options.allowShared && !isSharedArrayBuffer(value) && !isNonSharedArrayBuffer(value)) {
|
||||
throw makeException(TypeError, "is not an ArrayBuffer, SharedArrayBuffer, or a view on one", options);
|
||||
}
|
||||
if (isArrayBufferDetached(value)) {
|
||||
throw makeException(TypeError, "is a detached ArrayBuffer", options);
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
exports.DOMTimeStamp = exports["unsigned long long"];
|
||||
32
node_modules/jsdom/node_modules/webidl-conversions/package.json
generated
vendored
Normal file
32
node_modules/jsdom/node_modules/webidl-conversions/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"name": "webidl-conversions",
|
||||
"version": "7.0.0",
|
||||
"description": "Implements the WebIDL algorithms for converting to and from JavaScript values",
|
||||
"main": "lib/index.js",
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"test": "mocha test/*.js",
|
||||
"test-no-sab": "mocha --parallel --jobs 2 --require test/helpers/delete-sab.js test/*.js",
|
||||
"coverage": "nyc mocha test/*.js"
|
||||
},
|
||||
"repository": "jsdom/webidl-conversions",
|
||||
"keywords": [
|
||||
"webidl",
|
||||
"web",
|
||||
"types"
|
||||
],
|
||||
"files": [
|
||||
"lib/"
|
||||
],
|
||||
"author": "Domenic Denicola <d@domenic.me> (https://domenic.me/)",
|
||||
"license": "BSD-2-Clause",
|
||||
"devDependencies": {
|
||||
"@domenic/eslint-config": "^1.3.0",
|
||||
"eslint": "^7.32.0",
|
||||
"mocha": "^9.1.1",
|
||||
"nyc": "^15.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
}
|
||||
21
node_modules/jsdom/node_modules/whatwg-url/LICENSE.txt
generated
vendored
Normal file
21
node_modules/jsdom/node_modules/whatwg-url/LICENSE.txt
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sebastian Mayr
|
||||
|
||||
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.
|
||||
106
node_modules/jsdom/node_modules/whatwg-url/README.md
generated
vendored
Normal file
106
node_modules/jsdom/node_modules/whatwg-url/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
# whatwg-url
|
||||
|
||||
whatwg-url is a full implementation of the WHATWG [URL Standard](https://url.spec.whatwg.org/). It can be used standalone, but it also exposes a lot of the internal algorithms that are useful for integrating a URL parser into a project like [jsdom](https://github.com/jsdom/jsdom).
|
||||
|
||||
## Specification conformance
|
||||
|
||||
whatwg-url is currently up to date with the URL spec up to commit [6c78200](https://github.com/whatwg/url/commit/6c782003a2d53b1feecd072d1006eb8f1d65fb2d).
|
||||
|
||||
For `file:` URLs, whose [origin is left unspecified](https://url.spec.whatwg.org/#concept-url-origin), whatwg-url chooses to use a new opaque origin (which serializes to `"null"`).
|
||||
|
||||
whatwg-url does not yet implement any encoding handling beyond UTF-8. That is, the _encoding override_ parameter does not exist in our API.
|
||||
|
||||
## API
|
||||
|
||||
### The `URL` and `URLSearchParams` classes
|
||||
|
||||
The main API is provided by the [`URL`](https://url.spec.whatwg.org/#url-class) and [`URLSearchParams`](https://url.spec.whatwg.org/#interface-urlsearchparams) exports, which follows the spec's behavior in all ways (including e.g. `USVString` conversion). Most consumers of this library will want to use these.
|
||||
|
||||
### Low-level URL Standard API
|
||||
|
||||
The following methods are exported for use by places like jsdom that need to implement things like [`HTMLHyperlinkElementUtils`](https://html.spec.whatwg.org/#htmlhyperlinkelementutils). They mostly operate on or return an "internal URL" or ["URL record"](https://url.spec.whatwg.org/#concept-url) type.
|
||||
|
||||
- [URL parser](https://url.spec.whatwg.org/#concept-url-parser): `parseURL(input, { baseURL })`
|
||||
- [Basic URL parser](https://url.spec.whatwg.org/#concept-basic-url-parser): `basicURLParse(input, { baseURL, url, stateOverride })`
|
||||
- [URL serializer](https://url.spec.whatwg.org/#concept-url-serializer): `serializeURL(urlRecord, excludeFragment)`
|
||||
- [Host serializer](https://url.spec.whatwg.org/#concept-host-serializer): `serializeHost(hostFromURLRecord)`
|
||||
- [URL path serializer](https://url.spec.whatwg.org/#url-path-serializer): `serializePath(urlRecord)`
|
||||
- [Serialize an integer](https://url.spec.whatwg.org/#serialize-an-integer): `serializeInteger(number)`
|
||||
- [Origin](https://url.spec.whatwg.org/#concept-url-origin) [serializer](https://html.spec.whatwg.org/multipage/origin.html#ascii-serialisation-of-an-origin): `serializeURLOrigin(urlRecord)`
|
||||
- [Set the username](https://url.spec.whatwg.org/#set-the-username): `setTheUsername(urlRecord, usernameString)`
|
||||
- [Set the password](https://url.spec.whatwg.org/#set-the-password): `setThePassword(urlRecord, passwordString)`
|
||||
- [Has an opaque path](https://url.spec.whatwg.org/#url-opaque-path): `hasAnOpaquePath(urlRecord)`
|
||||
- [Cannot have a username/password/port](https://url.spec.whatwg.org/#cannot-have-a-username-password-port): `cannotHaveAUsernamePasswordPort(urlRecord)`
|
||||
- [Percent decode bytes](https://url.spec.whatwg.org/#percent-decode): `percentDecodeBytes(uint8Array)`
|
||||
- [Percent decode a string](https://url.spec.whatwg.org/#string-percent-decode): `percentDecodeString(string)`
|
||||
|
||||
The `stateOverride` parameter is one of the following strings:
|
||||
|
||||
- [`"scheme start"`](https://url.spec.whatwg.org/#scheme-start-state)
|
||||
- [`"scheme"`](https://url.spec.whatwg.org/#scheme-state)
|
||||
- [`"no scheme"`](https://url.spec.whatwg.org/#no-scheme-state)
|
||||
- [`"special relative or authority"`](https://url.spec.whatwg.org/#special-relative-or-authority-state)
|
||||
- [`"path or authority"`](https://url.spec.whatwg.org/#path-or-authority-state)
|
||||
- [`"relative"`](https://url.spec.whatwg.org/#relative-state)
|
||||
- [`"relative slash"`](https://url.spec.whatwg.org/#relative-slash-state)
|
||||
- [`"special authority slashes"`](https://url.spec.whatwg.org/#special-authority-slashes-state)
|
||||
- [`"special authority ignore slashes"`](https://url.spec.whatwg.org/#special-authority-ignore-slashes-state)
|
||||
- [`"authority"`](https://url.spec.whatwg.org/#authority-state)
|
||||
- [`"host"`](https://url.spec.whatwg.org/#host-state)
|
||||
- [`"hostname"`](https://url.spec.whatwg.org/#hostname-state)
|
||||
- [`"port"`](https://url.spec.whatwg.org/#port-state)
|
||||
- [`"file"`](https://url.spec.whatwg.org/#file-state)
|
||||
- [`"file slash"`](https://url.spec.whatwg.org/#file-slash-state)
|
||||
- [`"file host"`](https://url.spec.whatwg.org/#file-host-state)
|
||||
- [`"path start"`](https://url.spec.whatwg.org/#path-start-state)
|
||||
- [`"path"`](https://url.spec.whatwg.org/#path-state)
|
||||
- [`"opaque path"`](https://url.spec.whatwg.org/#cannot-be-a-base-url-path-state)
|
||||
- [`"query"`](https://url.spec.whatwg.org/#query-state)
|
||||
- [`"fragment"`](https://url.spec.whatwg.org/#fragment-state)
|
||||
|
||||
The URL record type has the following API:
|
||||
|
||||
- [`scheme`](https://url.spec.whatwg.org/#concept-url-scheme)
|
||||
- [`username`](https://url.spec.whatwg.org/#concept-url-username)
|
||||
- [`password`](https://url.spec.whatwg.org/#concept-url-password)
|
||||
- [`host`](https://url.spec.whatwg.org/#concept-url-host)
|
||||
- [`port`](https://url.spec.whatwg.org/#concept-url-port)
|
||||
- [`path`](https://url.spec.whatwg.org/#concept-url-path) (as an array of strings, or a string)
|
||||
- [`query`](https://url.spec.whatwg.org/#concept-url-query)
|
||||
- [`fragment`](https://url.spec.whatwg.org/#concept-url-fragment)
|
||||
|
||||
These properties should be treated with care, as in general changing them will cause the URL record to be in an inconsistent state until the appropriate invocation of `basicURLParse` is used to fix it up. You can see examples of this in the URL Standard, where there are many step sequences like "4. Set context object’s url’s fragment to the empty string. 5. Basic URL parse _input_ with context object’s url as _url_ and fragment state as _state override_." In between those two steps, a URL record is in an unusable state.
|
||||
|
||||
The return value of "failure" in the spec is represented by `null`. That is, functions like `parseURL` and `basicURLParse` can return _either_ a URL record _or_ `null`.
|
||||
|
||||
### `whatwg-url/webidl2js-wrapper` module
|
||||
|
||||
This module exports the `URL` and `URLSearchParams` [interface wrappers API](https://github.com/jsdom/webidl2js#for-interfaces) generated by [webidl2js](https://github.com/jsdom/webidl2js).
|
||||
|
||||
## Development instructions
|
||||
|
||||
First, install [Node.js](https://nodejs.org/). Then, fetch the dependencies of whatwg-url, by running from this directory:
|
||||
|
||||
npm install
|
||||
|
||||
To run tests:
|
||||
|
||||
npm test
|
||||
|
||||
To generate a coverage report:
|
||||
|
||||
npm run coverage
|
||||
|
||||
To build and run the live viewer:
|
||||
|
||||
npm run prepare
|
||||
npm run build-live-viewer
|
||||
|
||||
Serve the contents of the `live-viewer` directory using any web server.
|
||||
|
||||
## Supporting whatwg-url
|
||||
|
||||
The jsdom project (including whatwg-url) is a community-driven project maintained by a team of [volunteers](https://github.com/orgs/jsdom/people). You could support us by:
|
||||
|
||||
- [Getting professional support for whatwg-url](https://tidelift.com/subscription/pkg/npm-whatwg-url?utm_source=npm-whatwg-url&utm_medium=referral&utm_campaign=readme) as part of a Tidelift subscription. Tidelift helps making open source sustainable for us while giving teams assurances for maintenance, licensing, and security.
|
||||
- Contributing directly to the project.
|
||||
27
node_modules/jsdom/node_modules/whatwg-url/index.js
generated
vendored
Normal file
27
node_modules/jsdom/node_modules/whatwg-url/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
"use strict";
|
||||
|
||||
const { URL, URLSearchParams } = require("./webidl2js-wrapper");
|
||||
const urlStateMachine = require("./lib/url-state-machine");
|
||||
const percentEncoding = require("./lib/percent-encoding");
|
||||
|
||||
const sharedGlobalObject = { Array, Object, Promise, String, TypeError };
|
||||
URL.install(sharedGlobalObject, ["Window"]);
|
||||
URLSearchParams.install(sharedGlobalObject, ["Window"]);
|
||||
|
||||
exports.URL = sharedGlobalObject.URL;
|
||||
exports.URLSearchParams = sharedGlobalObject.URLSearchParams;
|
||||
|
||||
exports.parseURL = urlStateMachine.parseURL;
|
||||
exports.basicURLParse = urlStateMachine.basicURLParse;
|
||||
exports.serializeURL = urlStateMachine.serializeURL;
|
||||
exports.serializePath = urlStateMachine.serializePath;
|
||||
exports.serializeHost = urlStateMachine.serializeHost;
|
||||
exports.serializeInteger = urlStateMachine.serializeInteger;
|
||||
exports.serializeURLOrigin = urlStateMachine.serializeURLOrigin;
|
||||
exports.setTheUsername = urlStateMachine.setTheUsername;
|
||||
exports.setThePassword = urlStateMachine.setThePassword;
|
||||
exports.cannotHaveAUsernamePasswordPort = urlStateMachine.cannotHaveAUsernamePasswordPort;
|
||||
exports.hasAnOpaquePath = urlStateMachine.hasAnOpaquePath;
|
||||
|
||||
exports.percentDecodeString = percentEncoding.percentDecodeString;
|
||||
exports.percentDecodeBytes = percentEncoding.percentDecodeBytes;
|
||||
42
node_modules/jsdom/node_modules/whatwg-url/lib/Function.js
generated
vendored
Normal file
42
node_modules/jsdom/node_modules/whatwg-url/lib/Function.js
generated
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
|
||||
if (typeof value !== "function") {
|
||||
throw new globalObject.TypeError(context + " is not a function");
|
||||
}
|
||||
|
||||
function invokeTheCallbackFunction(...args) {
|
||||
const thisArg = utils.tryWrapperForImpl(this);
|
||||
let callResult;
|
||||
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
args[i] = utils.tryWrapperForImpl(args[i]);
|
||||
}
|
||||
|
||||
callResult = Reflect.apply(value, thisArg, args);
|
||||
|
||||
callResult = conversions["any"](callResult, { context: context, globals: globalObject });
|
||||
|
||||
return callResult;
|
||||
}
|
||||
|
||||
invokeTheCallbackFunction.construct = (...args) => {
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
args[i] = utils.tryWrapperForImpl(args[i]);
|
||||
}
|
||||
|
||||
let callResult = Reflect.construct(value, args);
|
||||
|
||||
callResult = conversions["any"](callResult, { context: context, globals: globalObject });
|
||||
|
||||
return callResult;
|
||||
};
|
||||
|
||||
invokeTheCallbackFunction[utils.wrapperSymbol] = value;
|
||||
invokeTheCallbackFunction.objectReference = value;
|
||||
|
||||
return invokeTheCallbackFunction;
|
||||
};
|
||||
233
node_modules/jsdom/node_modules/whatwg-url/lib/URL-impl.js
generated
vendored
Normal file
233
node_modules/jsdom/node_modules/whatwg-url/lib/URL-impl.js
generated
vendored
Normal file
|
|
@ -0,0 +1,233 @@
|
|||
"use strict";
|
||||
const usm = require("./url-state-machine");
|
||||
const urlencoded = require("./urlencoded");
|
||||
const URLSearchParams = require("./URLSearchParams");
|
||||
|
||||
exports.implementation = class URLImpl {
|
||||
// Unlike the spec, we duplicate some code between the constructor and canParse, because we want to give useful error
|
||||
// messages in the constructor that distinguish between the different causes of failure.
|
||||
constructor(globalObject, [url, base]) {
|
||||
let parsedBase = null;
|
||||
if (base !== undefined) {
|
||||
parsedBase = usm.basicURLParse(base);
|
||||
if (parsedBase === null) {
|
||||
throw new TypeError(`Invalid base URL: ${base}`);
|
||||
}
|
||||
}
|
||||
|
||||
const parsedURL = usm.basicURLParse(url, { baseURL: parsedBase });
|
||||
if (parsedURL === null) {
|
||||
throw new TypeError(`Invalid URL: ${url}`);
|
||||
}
|
||||
|
||||
const query = parsedURL.query !== null ? parsedURL.query : "";
|
||||
|
||||
this._url = parsedURL;
|
||||
|
||||
// We cannot invoke the "new URLSearchParams object" algorithm without going through the constructor, which strips
|
||||
// question mark by default. Therefore the doNotStripQMark hack is used.
|
||||
this._query = URLSearchParams.createImpl(globalObject, [query], { doNotStripQMark: true });
|
||||
this._query._url = this;
|
||||
}
|
||||
|
||||
static parse(globalObject, input, base) {
|
||||
try {
|
||||
return new URLImpl(globalObject, [input, base]);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static canParse(url, base) {
|
||||
let parsedBase = null;
|
||||
if (base !== undefined) {
|
||||
parsedBase = usm.basicURLParse(base);
|
||||
if (parsedBase === null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const parsedURL = usm.basicURLParse(url, { baseURL: parsedBase });
|
||||
if (parsedURL === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
get href() {
|
||||
return usm.serializeURL(this._url);
|
||||
}
|
||||
|
||||
set href(v) {
|
||||
const parsedURL = usm.basicURLParse(v);
|
||||
if (parsedURL === null) {
|
||||
throw new TypeError(`Invalid URL: ${v}`);
|
||||
}
|
||||
|
||||
this._url = parsedURL;
|
||||
|
||||
this._query._list.splice(0);
|
||||
const { query } = parsedURL;
|
||||
if (query !== null) {
|
||||
this._query._list = urlencoded.parseUrlencodedString(query);
|
||||
}
|
||||
}
|
||||
|
||||
get origin() {
|
||||
return usm.serializeURLOrigin(this._url);
|
||||
}
|
||||
|
||||
get protocol() {
|
||||
return `${this._url.scheme}:`;
|
||||
}
|
||||
|
||||
set protocol(v) {
|
||||
usm.basicURLParse(`${v}:`, { url: this._url, stateOverride: "scheme start" });
|
||||
}
|
||||
|
||||
get username() {
|
||||
return this._url.username;
|
||||
}
|
||||
|
||||
set username(v) {
|
||||
if (usm.cannotHaveAUsernamePasswordPort(this._url)) {
|
||||
return;
|
||||
}
|
||||
|
||||
usm.setTheUsername(this._url, v);
|
||||
}
|
||||
|
||||
get password() {
|
||||
return this._url.password;
|
||||
}
|
||||
|
||||
set password(v) {
|
||||
if (usm.cannotHaveAUsernamePasswordPort(this._url)) {
|
||||
return;
|
||||
}
|
||||
|
||||
usm.setThePassword(this._url, v);
|
||||
}
|
||||
|
||||
get host() {
|
||||
const url = this._url;
|
||||
|
||||
if (url.host === null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (url.port === null) {
|
||||
return usm.serializeHost(url.host);
|
||||
}
|
||||
|
||||
return `${usm.serializeHost(url.host)}:${usm.serializeInteger(url.port)}`;
|
||||
}
|
||||
|
||||
set host(v) {
|
||||
if (usm.hasAnOpaquePath(this._url)) {
|
||||
return;
|
||||
}
|
||||
|
||||
usm.basicURLParse(v, { url: this._url, stateOverride: "host" });
|
||||
}
|
||||
|
||||
get hostname() {
|
||||
if (this._url.host === null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return usm.serializeHost(this._url.host);
|
||||
}
|
||||
|
||||
set hostname(v) {
|
||||
if (usm.hasAnOpaquePath(this._url)) {
|
||||
return;
|
||||
}
|
||||
|
||||
usm.basicURLParse(v, { url: this._url, stateOverride: "hostname" });
|
||||
}
|
||||
|
||||
get port() {
|
||||
if (this._url.port === null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return usm.serializeInteger(this._url.port);
|
||||
}
|
||||
|
||||
set port(v) {
|
||||
if (usm.cannotHaveAUsernamePasswordPort(this._url)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (v === "") {
|
||||
this._url.port = null;
|
||||
} else {
|
||||
usm.basicURLParse(v, { url: this._url, stateOverride: "port" });
|
||||
}
|
||||
}
|
||||
|
||||
get pathname() {
|
||||
return usm.serializePath(this._url);
|
||||
}
|
||||
|
||||
set pathname(v) {
|
||||
if (usm.hasAnOpaquePath(this._url)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._url.path = [];
|
||||
usm.basicURLParse(v, { url: this._url, stateOverride: "path start" });
|
||||
}
|
||||
|
||||
get search() {
|
||||
if (this._url.query === null || this._url.query === "") {
|
||||
return "";
|
||||
}
|
||||
|
||||
return `?${this._url.query}`;
|
||||
}
|
||||
|
||||
set search(v) {
|
||||
const url = this._url;
|
||||
|
||||
if (v === "") {
|
||||
url.query = null;
|
||||
this._query._list = [];
|
||||
return;
|
||||
}
|
||||
|
||||
const input = v[0] === "?" ? v.substring(1) : v;
|
||||
url.query = "";
|
||||
usm.basicURLParse(input, { url, stateOverride: "query" });
|
||||
this._query._list = urlencoded.parseUrlencodedString(input);
|
||||
}
|
||||
|
||||
get searchParams() {
|
||||
return this._query;
|
||||
}
|
||||
|
||||
get hash() {
|
||||
if (this._url.fragment === null || this._url.fragment === "") {
|
||||
return "";
|
||||
}
|
||||
|
||||
return `#${this._url.fragment}`;
|
||||
}
|
||||
|
||||
set hash(v) {
|
||||
if (v === "") {
|
||||
this._url.fragment = null;
|
||||
return;
|
||||
}
|
||||
|
||||
const input = v[0] === "#" ? v.substring(1) : v;
|
||||
this._url.fragment = "";
|
||||
usm.basicURLParse(input, { url: this._url, stateOverride: "fragment" });
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return this.href;
|
||||
}
|
||||
};
|
||||
499
node_modules/jsdom/node_modules/whatwg-url/lib/URL.js
generated
vendored
Normal file
499
node_modules/jsdom/node_modules/whatwg-url/lib/URL.js
generated
vendored
Normal file
|
|
@ -0,0 +1,499 @@
|
|||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
|
||||
const interfaceName = "URL";
|
||||
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
throw new globalObject.TypeError(`${context} is not of type 'URL'.`);
|
||||
};
|
||||
|
||||
function makeWrapper(globalObject, newTarget) {
|
||||
let proto;
|
||||
if (newTarget !== undefined) {
|
||||
proto = newTarget.prototype;
|
||||
}
|
||||
|
||||
if (!utils.isObject(proto)) {
|
||||
proto = globalObject[ctorRegistrySymbol]["URL"].prototype;
|
||||
}
|
||||
|
||||
return Object.create(proto);
|
||||
}
|
||||
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
exports._internalSetup = (wrapper, globalObject) => {};
|
||||
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
exports.new = (globalObject, newTarget) => {
|
||||
const wrapper = makeWrapper(globalObject, newTarget);
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
const exposed = new Set(["Window", "Worker"]);
|
||||
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
|
||||
const ctorRegistry = utils.initCtorRegistry(globalObject);
|
||||
class URL {
|
||||
constructor(url) {
|
||||
if (arguments.length < 1) {
|
||||
throw new globalObject.TypeError(
|
||||
`Failed to construct 'URL': 1 argument required, but only ${arguments.length} present.`
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to construct 'URL': parameter 1",
|
||||
globals: globalObject
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to construct 'URL': parameter 2",
|
||||
globals: globalObject
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return exports.setup(Object.create(new.target.prototype), globalObject, args);
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError("'toJSON' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
return esValue[implSymbol].toJSON();
|
||||
}
|
||||
|
||||
get href() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError("'get href' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["href"];
|
||||
}
|
||||
|
||||
set href(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError("'set href' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
V = conversions["USVString"](V, {
|
||||
context: "Failed to set the 'href' property on 'URL': The provided value",
|
||||
globals: globalObject
|
||||
});
|
||||
|
||||
esValue[implSymbol]["href"] = V;
|
||||
}
|
||||
|
||||
toString() {
|
||||
const esValue = this;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError("'toString' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["href"];
|
||||
}
|
||||
|
||||
get origin() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError("'get origin' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["origin"];
|
||||
}
|
||||
|
||||
get protocol() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError("'get protocol' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["protocol"];
|
||||
}
|
||||
|
||||
set protocol(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError("'set protocol' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
V = conversions["USVString"](V, {
|
||||
context: "Failed to set the 'protocol' property on 'URL': The provided value",
|
||||
globals: globalObject
|
||||
});
|
||||
|
||||
esValue[implSymbol]["protocol"] = V;
|
||||
}
|
||||
|
||||
get username() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError("'get username' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["username"];
|
||||
}
|
||||
|
||||
set username(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError("'set username' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
V = conversions["USVString"](V, {
|
||||
context: "Failed to set the 'username' property on 'URL': The provided value",
|
||||
globals: globalObject
|
||||
});
|
||||
|
||||
esValue[implSymbol]["username"] = V;
|
||||
}
|
||||
|
||||
get password() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError("'get password' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["password"];
|
||||
}
|
||||
|
||||
set password(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError("'set password' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
V = conversions["USVString"](V, {
|
||||
context: "Failed to set the 'password' property on 'URL': The provided value",
|
||||
globals: globalObject
|
||||
});
|
||||
|
||||
esValue[implSymbol]["password"] = V;
|
||||
}
|
||||
|
||||
get host() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError("'get host' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["host"];
|
||||
}
|
||||
|
||||
set host(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError("'set host' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
V = conversions["USVString"](V, {
|
||||
context: "Failed to set the 'host' property on 'URL': The provided value",
|
||||
globals: globalObject
|
||||
});
|
||||
|
||||
esValue[implSymbol]["host"] = V;
|
||||
}
|
||||
|
||||
get hostname() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError("'get hostname' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["hostname"];
|
||||
}
|
||||
|
||||
set hostname(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError("'set hostname' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
V = conversions["USVString"](V, {
|
||||
context: "Failed to set the 'hostname' property on 'URL': The provided value",
|
||||
globals: globalObject
|
||||
});
|
||||
|
||||
esValue[implSymbol]["hostname"] = V;
|
||||
}
|
||||
|
||||
get port() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError("'get port' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["port"];
|
||||
}
|
||||
|
||||
set port(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError("'set port' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
V = conversions["USVString"](V, {
|
||||
context: "Failed to set the 'port' property on 'URL': The provided value",
|
||||
globals: globalObject
|
||||
});
|
||||
|
||||
esValue[implSymbol]["port"] = V;
|
||||
}
|
||||
|
||||
get pathname() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError("'get pathname' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["pathname"];
|
||||
}
|
||||
|
||||
set pathname(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError("'set pathname' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
V = conversions["USVString"](V, {
|
||||
context: "Failed to set the 'pathname' property on 'URL': The provided value",
|
||||
globals: globalObject
|
||||
});
|
||||
|
||||
esValue[implSymbol]["pathname"] = V;
|
||||
}
|
||||
|
||||
get search() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError("'get search' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["search"];
|
||||
}
|
||||
|
||||
set search(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError("'set search' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
V = conversions["USVString"](V, {
|
||||
context: "Failed to set the 'search' property on 'URL': The provided value",
|
||||
globals: globalObject
|
||||
});
|
||||
|
||||
esValue[implSymbol]["search"] = V;
|
||||
}
|
||||
|
||||
get searchParams() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError("'get searchParams' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
return utils.getSameObject(this, "searchParams", () => {
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol]["searchParams"]);
|
||||
});
|
||||
}
|
||||
|
||||
get hash() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError("'get hash' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["hash"];
|
||||
}
|
||||
|
||||
set hash(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError("'set hash' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
V = conversions["USVString"](V, {
|
||||
context: "Failed to set the 'hash' property on 'URL': The provided value",
|
||||
globals: globalObject
|
||||
});
|
||||
|
||||
esValue[implSymbol]["hash"] = V;
|
||||
}
|
||||
|
||||
static parse(url) {
|
||||
if (arguments.length < 1) {
|
||||
throw new globalObject.TypeError(
|
||||
`Failed to execute 'parse' on 'URL': 1 argument required, but only ${arguments.length} present.`
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'parse' on 'URL': parameter 1",
|
||||
globals: globalObject
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'parse' on 'URL': parameter 2",
|
||||
globals: globalObject
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return utils.tryWrapperForImpl(Impl.implementation.parse(globalObject, ...args));
|
||||
}
|
||||
|
||||
static canParse(url) {
|
||||
if (arguments.length < 1) {
|
||||
throw new globalObject.TypeError(
|
||||
`Failed to execute 'canParse' on 'URL': 1 argument required, but only ${arguments.length} present.`
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'canParse' on 'URL': parameter 1",
|
||||
globals: globalObject
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'canParse' on 'URL': parameter 2",
|
||||
globals: globalObject
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return Impl.implementation.canParse(...args);
|
||||
}
|
||||
}
|
||||
Object.defineProperties(URL.prototype, {
|
||||
toJSON: { enumerable: true },
|
||||
href: { enumerable: true },
|
||||
toString: { enumerable: true },
|
||||
origin: { enumerable: true },
|
||||
protocol: { enumerable: true },
|
||||
username: { enumerable: true },
|
||||
password: { enumerable: true },
|
||||
host: { enumerable: true },
|
||||
hostname: { enumerable: true },
|
||||
port: { enumerable: true },
|
||||
pathname: { enumerable: true },
|
||||
search: { enumerable: true },
|
||||
searchParams: { enumerable: true },
|
||||
hash: { enumerable: true },
|
||||
[Symbol.toStringTag]: { value: "URL", configurable: true }
|
||||
});
|
||||
Object.defineProperties(URL, { parse: { enumerable: true }, canParse: { enumerable: true } });
|
||||
ctorRegistry[interfaceName] = URL;
|
||||
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: URL
|
||||
});
|
||||
|
||||
if (globalNames.includes("Window")) {
|
||||
Object.defineProperty(globalObject, "webkitURL", {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: URL
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const Impl = require("./URL-impl.js");
|
||||
135
node_modules/jsdom/node_modules/whatwg-url/lib/URLSearchParams-impl.js
generated
vendored
Normal file
135
node_modules/jsdom/node_modules/whatwg-url/lib/URLSearchParams-impl.js
generated
vendored
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
"use strict";
|
||||
const urlencoded = require("./urlencoded");
|
||||
|
||||
exports.implementation = class URLSearchParamsImpl {
|
||||
constructor(globalObject, constructorArgs, { doNotStripQMark = false }) {
|
||||
let init = constructorArgs[0];
|
||||
this._list = [];
|
||||
this._url = null;
|
||||
|
||||
if (!doNotStripQMark && typeof init === "string" && init[0] === "?") {
|
||||
init = init.slice(1);
|
||||
}
|
||||
|
||||
if (Array.isArray(init)) {
|
||||
for (const pair of init) {
|
||||
if (pair.length !== 2) {
|
||||
throw new TypeError("Failed to construct 'URLSearchParams': parameter 1 sequence's element does not " +
|
||||
"contain exactly two elements.");
|
||||
}
|
||||
this._list.push([pair[0], pair[1]]);
|
||||
}
|
||||
} else if (typeof init === "object" && Object.getPrototypeOf(init) === null) {
|
||||
for (const name of Object.keys(init)) {
|
||||
const value = init[name];
|
||||
this._list.push([name, value]);
|
||||
}
|
||||
} else {
|
||||
this._list = urlencoded.parseUrlencodedString(init);
|
||||
}
|
||||
}
|
||||
|
||||
_updateSteps() {
|
||||
if (this._url !== null) {
|
||||
let serializedQuery = urlencoded.serializeUrlencoded(this._list);
|
||||
if (serializedQuery === "") {
|
||||
serializedQuery = null;
|
||||
}
|
||||
|
||||
this._url._url.query = serializedQuery;
|
||||
}
|
||||
}
|
||||
|
||||
get size() {
|
||||
return this._list.length;
|
||||
}
|
||||
|
||||
append(name, value) {
|
||||
this._list.push([name, value]);
|
||||
this._updateSteps();
|
||||
}
|
||||
|
||||
delete(name, value) {
|
||||
let i = 0;
|
||||
while (i < this._list.length) {
|
||||
if (this._list[i][0] === name && (value === undefined || this._list[i][1] === value)) {
|
||||
this._list.splice(i, 1);
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
this._updateSteps();
|
||||
}
|
||||
|
||||
get(name) {
|
||||
for (const tuple of this._list) {
|
||||
if (tuple[0] === name) {
|
||||
return tuple[1];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
getAll(name) {
|
||||
const output = [];
|
||||
for (const tuple of this._list) {
|
||||
if (tuple[0] === name) {
|
||||
output.push(tuple[1]);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
has(name, value) {
|
||||
for (const tuple of this._list) {
|
||||
if (tuple[0] === name && (value === undefined || tuple[1] === value)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
set(name, value) {
|
||||
let found = false;
|
||||
let i = 0;
|
||||
while (i < this._list.length) {
|
||||
if (this._list[i][0] === name) {
|
||||
if (found) {
|
||||
this._list.splice(i, 1);
|
||||
} else {
|
||||
found = true;
|
||||
this._list[i][1] = value;
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
this._list.push([name, value]);
|
||||
}
|
||||
this._updateSteps();
|
||||
}
|
||||
|
||||
sort() {
|
||||
this._list.sort((a, b) => {
|
||||
if (a[0] < b[0]) {
|
||||
return -1;
|
||||
}
|
||||
if (a[0] > b[0]) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
this._updateSteps();
|
||||
}
|
||||
|
||||
[Symbol.iterator]() {
|
||||
return this._list[Symbol.iterator]();
|
||||
}
|
||||
|
||||
toString() {
|
||||
return urlencoded.serializeUrlencoded(this._list);
|
||||
}
|
||||
};
|
||||
505
node_modules/jsdom/node_modules/whatwg-url/lib/URLSearchParams.js
generated
vendored
Normal file
505
node_modules/jsdom/node_modules/whatwg-url/lib/URLSearchParams.js
generated
vendored
Normal file
|
|
@ -0,0 +1,505 @@
|
|||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const Function = require("./Function.js");
|
||||
const newObjectInRealm = utils.newObjectInRealm;
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
|
||||
const interfaceName = "URLSearchParams";
|
||||
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
throw new globalObject.TypeError(`${context} is not of type 'URLSearchParams'.`);
|
||||
};
|
||||
|
||||
exports.createDefaultIterator = (globalObject, target, kind) => {
|
||||
const ctorRegistry = globalObject[ctorRegistrySymbol];
|
||||
const iteratorPrototype = ctorRegistry["URLSearchParams Iterator"];
|
||||
const iterator = Object.create(iteratorPrototype);
|
||||
Object.defineProperty(iterator, utils.iterInternalSymbol, {
|
||||
value: { target, kind, index: 0 },
|
||||
configurable: true
|
||||
});
|
||||
return iterator;
|
||||
};
|
||||
|
||||
function makeWrapper(globalObject, newTarget) {
|
||||
let proto;
|
||||
if (newTarget !== undefined) {
|
||||
proto = newTarget.prototype;
|
||||
}
|
||||
|
||||
if (!utils.isObject(proto)) {
|
||||
proto = globalObject[ctorRegistrySymbol]["URLSearchParams"].prototype;
|
||||
}
|
||||
|
||||
return Object.create(proto);
|
||||
}
|
||||
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
exports._internalSetup = (wrapper, globalObject) => {};
|
||||
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
exports.new = (globalObject, newTarget) => {
|
||||
const wrapper = makeWrapper(globalObject, newTarget);
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
const exposed = new Set(["Window", "Worker"]);
|
||||
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
|
||||
const ctorRegistry = utils.initCtorRegistry(globalObject);
|
||||
class URLSearchParams {
|
||||
constructor() {
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
if (curArg !== undefined) {
|
||||
if (utils.isObject(curArg)) {
|
||||
if (curArg[Symbol.iterator] !== undefined) {
|
||||
if (!utils.isObject(curArg)) {
|
||||
throw new globalObject.TypeError(
|
||||
"Failed to construct 'URLSearchParams': parameter 1" + " sequence" + " is not an iterable object."
|
||||
);
|
||||
} else {
|
||||
const V = [];
|
||||
const tmp = curArg;
|
||||
for (let nextItem of tmp) {
|
||||
if (!utils.isObject(nextItem)) {
|
||||
throw new globalObject.TypeError(
|
||||
"Failed to construct 'URLSearchParams': parameter 1" +
|
||||
" sequence" +
|
||||
"'s element" +
|
||||
" is not an iterable object."
|
||||
);
|
||||
} else {
|
||||
const V = [];
|
||||
const tmp = nextItem;
|
||||
for (let nextItem of tmp) {
|
||||
nextItem = conversions["USVString"](nextItem, {
|
||||
context:
|
||||
"Failed to construct 'URLSearchParams': parameter 1" +
|
||||
" sequence" +
|
||||
"'s element" +
|
||||
"'s element",
|
||||
globals: globalObject
|
||||
});
|
||||
|
||||
V.push(nextItem);
|
||||
}
|
||||
nextItem = V;
|
||||
}
|
||||
|
||||
V.push(nextItem);
|
||||
}
|
||||
curArg = V;
|
||||
}
|
||||
} else {
|
||||
if (!utils.isObject(curArg)) {
|
||||
throw new globalObject.TypeError(
|
||||
"Failed to construct 'URLSearchParams': parameter 1" + " record" + " is not an object."
|
||||
);
|
||||
} else {
|
||||
const result = Object.create(null);
|
||||
for (const key of Reflect.ownKeys(curArg)) {
|
||||
const desc = Object.getOwnPropertyDescriptor(curArg, key);
|
||||
if (desc && desc.enumerable) {
|
||||
let typedKey = key;
|
||||
|
||||
typedKey = conversions["USVString"](typedKey, {
|
||||
context: "Failed to construct 'URLSearchParams': parameter 1" + " record" + "'s key",
|
||||
globals: globalObject
|
||||
});
|
||||
|
||||
let typedValue = curArg[key];
|
||||
|
||||
typedValue = conversions["USVString"](typedValue, {
|
||||
context: "Failed to construct 'URLSearchParams': parameter 1" + " record" + "'s value",
|
||||
globals: globalObject
|
||||
});
|
||||
|
||||
result[typedKey] = typedValue;
|
||||
}
|
||||
}
|
||||
curArg = result;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to construct 'URLSearchParams': parameter 1",
|
||||
globals: globalObject
|
||||
});
|
||||
}
|
||||
} else {
|
||||
curArg = "";
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return exports.setup(Object.create(new.target.prototype), globalObject, args);
|
||||
}
|
||||
|
||||
append(name, value) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError(
|
||||
"'append' called on an object that is not a valid instance of URLSearchParams."
|
||||
);
|
||||
}
|
||||
|
||||
if (arguments.length < 2) {
|
||||
throw new globalObject.TypeError(
|
||||
`Failed to execute 'append' on 'URLSearchParams': 2 arguments required, but only ${arguments.length} present.`
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'append' on 'URLSearchParams': parameter 1",
|
||||
globals: globalObject
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'append' on 'URLSearchParams': parameter 2",
|
||||
globals: globalObject
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol].append(...args));
|
||||
}
|
||||
|
||||
delete(name) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError(
|
||||
"'delete' called on an object that is not a valid instance of URLSearchParams."
|
||||
);
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new globalObject.TypeError(
|
||||
`Failed to execute 'delete' on 'URLSearchParams': 1 argument required, but only ${arguments.length} present.`
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'delete' on 'URLSearchParams': parameter 1",
|
||||
globals: globalObject
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'delete' on 'URLSearchParams': parameter 2",
|
||||
globals: globalObject
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol].delete(...args));
|
||||
}
|
||||
|
||||
get(name) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError("'get' called on an object that is not a valid instance of URLSearchParams.");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new globalObject.TypeError(
|
||||
`Failed to execute 'get' on 'URLSearchParams': 1 argument required, but only ${arguments.length} present.`
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'get' on 'URLSearchParams': parameter 1",
|
||||
globals: globalObject
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return esValue[implSymbol].get(...args);
|
||||
}
|
||||
|
||||
getAll(name) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError(
|
||||
"'getAll' called on an object that is not a valid instance of URLSearchParams."
|
||||
);
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new globalObject.TypeError(
|
||||
`Failed to execute 'getAll' on 'URLSearchParams': 1 argument required, but only ${arguments.length} present.`
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'getAll' on 'URLSearchParams': parameter 1",
|
||||
globals: globalObject
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol].getAll(...args));
|
||||
}
|
||||
|
||||
has(name) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError("'has' called on an object that is not a valid instance of URLSearchParams.");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new globalObject.TypeError(
|
||||
`Failed to execute 'has' on 'URLSearchParams': 1 argument required, but only ${arguments.length} present.`
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'has' on 'URLSearchParams': parameter 1",
|
||||
globals: globalObject
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'has' on 'URLSearchParams': parameter 2",
|
||||
globals: globalObject
|
||||
});
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return esValue[implSymbol].has(...args);
|
||||
}
|
||||
|
||||
set(name, value) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError("'set' called on an object that is not a valid instance of URLSearchParams.");
|
||||
}
|
||||
|
||||
if (arguments.length < 2) {
|
||||
throw new globalObject.TypeError(
|
||||
`Failed to execute 'set' on 'URLSearchParams': 2 arguments required, but only ${arguments.length} present.`
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'set' on 'URLSearchParams': parameter 1",
|
||||
globals: globalObject
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'set' on 'URLSearchParams': parameter 2",
|
||||
globals: globalObject
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol].set(...args));
|
||||
}
|
||||
|
||||
sort() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError("'sort' called on an object that is not a valid instance of URLSearchParams.");
|
||||
}
|
||||
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol].sort());
|
||||
}
|
||||
|
||||
toString() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError(
|
||||
"'toString' called on an object that is not a valid instance of URLSearchParams."
|
||||
);
|
||||
}
|
||||
|
||||
return esValue[implSymbol].toString();
|
||||
}
|
||||
|
||||
keys() {
|
||||
if (!exports.is(this)) {
|
||||
throw new globalObject.TypeError("'keys' called on an object that is not a valid instance of URLSearchParams.");
|
||||
}
|
||||
return exports.createDefaultIterator(globalObject, this, "key");
|
||||
}
|
||||
|
||||
values() {
|
||||
if (!exports.is(this)) {
|
||||
throw new globalObject.TypeError(
|
||||
"'values' called on an object that is not a valid instance of URLSearchParams."
|
||||
);
|
||||
}
|
||||
return exports.createDefaultIterator(globalObject, this, "value");
|
||||
}
|
||||
|
||||
entries() {
|
||||
if (!exports.is(this)) {
|
||||
throw new globalObject.TypeError(
|
||||
"'entries' called on an object that is not a valid instance of URLSearchParams."
|
||||
);
|
||||
}
|
||||
return exports.createDefaultIterator(globalObject, this, "key+value");
|
||||
}
|
||||
|
||||
forEach(callback) {
|
||||
if (!exports.is(this)) {
|
||||
throw new globalObject.TypeError(
|
||||
"'forEach' called on an object that is not a valid instance of URLSearchParams."
|
||||
);
|
||||
}
|
||||
if (arguments.length < 1) {
|
||||
throw new globalObject.TypeError(
|
||||
"Failed to execute 'forEach' on 'iterable': 1 argument required, but only 0 present."
|
||||
);
|
||||
}
|
||||
callback = Function.convert(globalObject, callback, {
|
||||
context: "Failed to execute 'forEach' on 'iterable': The callback provided as parameter 1"
|
||||
});
|
||||
const thisArg = arguments[1];
|
||||
let pairs = Array.from(this[implSymbol]);
|
||||
let i = 0;
|
||||
while (i < pairs.length) {
|
||||
const [key, value] = pairs[i].map(utils.tryWrapperForImpl);
|
||||
callback.call(thisArg, value, key, this);
|
||||
pairs = Array.from(this[implSymbol]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
get size() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new globalObject.TypeError(
|
||||
"'get size' called on an object that is not a valid instance of URLSearchParams."
|
||||
);
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["size"];
|
||||
}
|
||||
}
|
||||
Object.defineProperties(URLSearchParams.prototype, {
|
||||
append: { enumerable: true },
|
||||
delete: { enumerable: true },
|
||||
get: { enumerable: true },
|
||||
getAll: { enumerable: true },
|
||||
has: { enumerable: true },
|
||||
set: { enumerable: true },
|
||||
sort: { enumerable: true },
|
||||
toString: { enumerable: true },
|
||||
keys: { enumerable: true },
|
||||
values: { enumerable: true },
|
||||
entries: { enumerable: true },
|
||||
forEach: { enumerable: true },
|
||||
size: { enumerable: true },
|
||||
[Symbol.toStringTag]: { value: "URLSearchParams", configurable: true },
|
||||
[Symbol.iterator]: { value: URLSearchParams.prototype.entries, configurable: true, writable: true }
|
||||
});
|
||||
ctorRegistry[interfaceName] = URLSearchParams;
|
||||
|
||||
ctorRegistry["URLSearchParams Iterator"] = Object.create(ctorRegistry["%IteratorPrototype%"], {
|
||||
[Symbol.toStringTag]: {
|
||||
configurable: true,
|
||||
value: "URLSearchParams Iterator"
|
||||
}
|
||||
});
|
||||
utils.define(ctorRegistry["URLSearchParams Iterator"], {
|
||||
next() {
|
||||
const internal = this && this[utils.iterInternalSymbol];
|
||||
if (!internal) {
|
||||
throw new globalObject.TypeError("next() called on a value that is not a URLSearchParams iterator object");
|
||||
}
|
||||
|
||||
const { target, kind, index } = internal;
|
||||
const values = Array.from(target[implSymbol]);
|
||||
const len = values.length;
|
||||
if (index >= len) {
|
||||
return newObjectInRealm(globalObject, { value: undefined, done: true });
|
||||
}
|
||||
|
||||
const pair = values[index];
|
||||
internal.index = index + 1;
|
||||
return newObjectInRealm(globalObject, utils.iteratorResult(pair.map(utils.tryWrapperForImpl), kind));
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: URLSearchParams
|
||||
});
|
||||
};
|
||||
|
||||
const Impl = require("./URLSearchParams-impl.js");
|
||||
26
node_modules/jsdom/node_modules/whatwg-url/lib/VoidFunction.js
generated
vendored
Normal file
26
node_modules/jsdom/node_modules/whatwg-url/lib/VoidFunction.js
generated
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
|
||||
if (typeof value !== "function") {
|
||||
throw new globalObject.TypeError(context + " is not a function");
|
||||
}
|
||||
|
||||
function invokeTheCallbackFunction() {
|
||||
const thisArg = utils.tryWrapperForImpl(this);
|
||||
let callResult;
|
||||
|
||||
callResult = Reflect.apply(value, thisArg, []);
|
||||
}
|
||||
|
||||
invokeTheCallbackFunction.construct = () => {
|
||||
let callResult = Reflect.construct(value, []);
|
||||
};
|
||||
|
||||
invokeTheCallbackFunction[utils.wrapperSymbol] = value;
|
||||
invokeTheCallbackFunction.objectReference = value;
|
||||
|
||||
return invokeTheCallbackFunction;
|
||||
};
|
||||
16
node_modules/jsdom/node_modules/whatwg-url/lib/encoding.js
generated
vendored
Normal file
16
node_modules/jsdom/node_modules/whatwg-url/lib/encoding.js
generated
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
"use strict";
|
||||
const utf8Encoder = new TextEncoder();
|
||||
const utf8Decoder = new TextDecoder("utf-8", { ignoreBOM: true });
|
||||
|
||||
function utf8Encode(string) {
|
||||
return utf8Encoder.encode(string);
|
||||
}
|
||||
|
||||
function utf8DecodeWithoutBOM(bytes) {
|
||||
return utf8Decoder.decode(bytes);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
utf8Encode,
|
||||
utf8DecodeWithoutBOM
|
||||
};
|
||||
26
node_modules/jsdom/node_modules/whatwg-url/lib/infra.js
generated
vendored
Normal file
26
node_modules/jsdom/node_modules/whatwg-url/lib/infra.js
generated
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
"use strict";
|
||||
|
||||
// Note that we take code points as JS numbers, not JS strings.
|
||||
|
||||
function isASCIIDigit(c) {
|
||||
return c >= 0x30 && c <= 0x39;
|
||||
}
|
||||
|
||||
function isASCIIAlpha(c) {
|
||||
return (c >= 0x41 && c <= 0x5A) || (c >= 0x61 && c <= 0x7A);
|
||||
}
|
||||
|
||||
function isASCIIAlphanumeric(c) {
|
||||
return isASCIIAlpha(c) || isASCIIDigit(c);
|
||||
}
|
||||
|
||||
function isASCIIHex(c) {
|
||||
return isASCIIDigit(c) || (c >= 0x41 && c <= 0x46) || (c >= 0x61 && c <= 0x66);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isASCIIDigit,
|
||||
isASCIIAlpha,
|
||||
isASCIIAlphanumeric,
|
||||
isASCIIHex
|
||||
};
|
||||
142
node_modules/jsdom/node_modules/whatwg-url/lib/percent-encoding.js
generated
vendored
Normal file
142
node_modules/jsdom/node_modules/whatwg-url/lib/percent-encoding.js
generated
vendored
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
"use strict";
|
||||
const { isASCIIHex } = require("./infra");
|
||||
const { utf8Encode } = require("./encoding");
|
||||
|
||||
function p(char) {
|
||||
return char.codePointAt(0);
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#percent-encode
|
||||
function percentEncode(c) {
|
||||
let hex = c.toString(16).toUpperCase();
|
||||
if (hex.length === 1) {
|
||||
hex = `0${hex}`;
|
||||
}
|
||||
|
||||
return `%${hex}`;
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#percent-decode
|
||||
function percentDecodeBytes(input) {
|
||||
const output = new Uint8Array(input.byteLength);
|
||||
let outputIndex = 0;
|
||||
for (let i = 0; i < input.byteLength; ++i) {
|
||||
const byte = input[i];
|
||||
if (byte !== 0x25) {
|
||||
output[outputIndex++] = byte;
|
||||
} else if (byte === 0x25 && (!isASCIIHex(input[i + 1]) || !isASCIIHex(input[i + 2]))) {
|
||||
output[outputIndex++] = byte;
|
||||
} else {
|
||||
const bytePoint = parseInt(String.fromCodePoint(input[i + 1], input[i + 2]), 16);
|
||||
output[outputIndex++] = bytePoint;
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
|
||||
return output.slice(0, outputIndex);
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#string-percent-decode
|
||||
function percentDecodeString(input) {
|
||||
const bytes = utf8Encode(input);
|
||||
return percentDecodeBytes(bytes);
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#c0-control-percent-encode-set
|
||||
function isC0ControlPercentEncode(c) {
|
||||
return c <= 0x1F || c > 0x7E;
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#fragment-percent-encode-set
|
||||
const extraFragmentPercentEncodeSet = new Set([p(" "), p("\""), p("<"), p(">"), p("`")]);
|
||||
function isFragmentPercentEncode(c) {
|
||||
return isC0ControlPercentEncode(c) || extraFragmentPercentEncodeSet.has(c);
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#query-percent-encode-set
|
||||
const extraQueryPercentEncodeSet = new Set([p(" "), p("\""), p("#"), p("<"), p(">")]);
|
||||
function isQueryPercentEncode(c) {
|
||||
return isC0ControlPercentEncode(c) || extraQueryPercentEncodeSet.has(c);
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#special-query-percent-encode-set
|
||||
function isSpecialQueryPercentEncode(c) {
|
||||
return isQueryPercentEncode(c) || c === p("'");
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#path-percent-encode-set
|
||||
const extraPathPercentEncodeSet = new Set([p("?"), p("`"), p("{"), p("}"), p("^")]);
|
||||
function isPathPercentEncode(c) {
|
||||
return isQueryPercentEncode(c) || extraPathPercentEncodeSet.has(c);
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#userinfo-percent-encode-set
|
||||
const extraUserinfoPercentEncodeSet =
|
||||
new Set([p("/"), p(":"), p(";"), p("="), p("@"), p("["), p("\\"), p("]"), p("|")]);
|
||||
function isUserinfoPercentEncode(c) {
|
||||
return isPathPercentEncode(c) || extraUserinfoPercentEncodeSet.has(c);
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#component-percent-encode-set
|
||||
const extraComponentPercentEncodeSet = new Set([p("$"), p("%"), p("&"), p("+"), p(",")]);
|
||||
function isComponentPercentEncode(c) {
|
||||
return isUserinfoPercentEncode(c) || extraComponentPercentEncodeSet.has(c);
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#application-x-www-form-urlencoded-percent-encode-set
|
||||
const extraURLEncodedPercentEncodeSet = new Set([p("!"), p("'"), p("("), p(")"), p("~")]);
|
||||
function isURLEncodedPercentEncode(c) {
|
||||
return isComponentPercentEncode(c) || extraURLEncodedPercentEncodeSet.has(c);
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#code-point-percent-encode-after-encoding
|
||||
// https://url.spec.whatwg.org/#utf-8-percent-encode
|
||||
// Assuming encoding is always utf-8 allows us to trim one of the logic branches. TODO: support encoding.
|
||||
// The "-Internal" variant here has code points as JS strings. The external version used by other files has code points
|
||||
// as JS numbers, like the rest of the codebase.
|
||||
function utf8PercentEncodeCodePointInternal(codePoint, percentEncodePredicate) {
|
||||
const bytes = utf8Encode(codePoint);
|
||||
let output = "";
|
||||
for (const byte of bytes) {
|
||||
// Our percentEncodePredicate operates on bytes, not code points, so this is slightly different from the spec.
|
||||
if (!percentEncodePredicate(byte)) {
|
||||
output += String.fromCharCode(byte);
|
||||
} else {
|
||||
output += percentEncode(byte);
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
function utf8PercentEncodeCodePoint(codePoint, percentEncodePredicate) {
|
||||
return utf8PercentEncodeCodePointInternal(String.fromCodePoint(codePoint), percentEncodePredicate);
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#string-percent-encode-after-encoding
|
||||
// https://url.spec.whatwg.org/#string-utf-8-percent-encode
|
||||
function utf8PercentEncodeString(input, percentEncodePredicate, spaceAsPlus = false) {
|
||||
let output = "";
|
||||
for (const codePoint of input) {
|
||||
if (spaceAsPlus && codePoint === " ") {
|
||||
output += "+";
|
||||
} else {
|
||||
output += utf8PercentEncodeCodePointInternal(codePoint, percentEncodePredicate);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isC0ControlPercentEncode,
|
||||
isFragmentPercentEncode,
|
||||
isQueryPercentEncode,
|
||||
isSpecialQueryPercentEncode,
|
||||
isPathPercentEncode,
|
||||
isUserinfoPercentEncode,
|
||||
isURLEncodedPercentEncode,
|
||||
percentDecodeString,
|
||||
percentDecodeBytes,
|
||||
utf8PercentEncodeString,
|
||||
utf8PercentEncodeCodePoint
|
||||
};
|
||||
1274
node_modules/jsdom/node_modules/whatwg-url/lib/url-state-machine.js
generated
vendored
Normal file
1274
node_modules/jsdom/node_modules/whatwg-url/lib/url-state-machine.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
89
node_modules/jsdom/node_modules/whatwg-url/lib/urlencoded.js
generated
vendored
Normal file
89
node_modules/jsdom/node_modules/whatwg-url/lib/urlencoded.js
generated
vendored
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
"use strict";
|
||||
const { utf8Encode, utf8DecodeWithoutBOM } = require("./encoding");
|
||||
const { percentDecodeBytes, utf8PercentEncodeString, isURLEncodedPercentEncode } = require("./percent-encoding");
|
||||
|
||||
function p(char) {
|
||||
return char.codePointAt(0);
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#concept-urlencoded-parser
|
||||
function parseUrlencoded(input) {
|
||||
const sequences = strictlySplitByteSequence(input, p("&"));
|
||||
const output = [];
|
||||
for (const bytes of sequences) {
|
||||
if (bytes.length === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let name, value;
|
||||
const indexOfEqual = bytes.indexOf(p("="));
|
||||
|
||||
if (indexOfEqual >= 0) {
|
||||
name = bytes.slice(0, indexOfEqual);
|
||||
value = bytes.slice(indexOfEqual + 1);
|
||||
} else {
|
||||
name = bytes;
|
||||
value = new Uint8Array(0);
|
||||
}
|
||||
|
||||
name = replaceByteInByteSequence(name, 0x2B, 0x20);
|
||||
value = replaceByteInByteSequence(value, 0x2B, 0x20);
|
||||
|
||||
const nameString = utf8DecodeWithoutBOM(percentDecodeBytes(name));
|
||||
const valueString = utf8DecodeWithoutBOM(percentDecodeBytes(value));
|
||||
|
||||
output.push([nameString, valueString]);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#concept-urlencoded-string-parser
|
||||
function parseUrlencodedString(input) {
|
||||
return parseUrlencoded(utf8Encode(input));
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#concept-urlencoded-serializer
|
||||
function serializeUrlencoded(tuples) {
|
||||
// TODO: accept and use encoding argument
|
||||
|
||||
let output = "";
|
||||
for (const [i, tuple] of tuples.entries()) {
|
||||
const name = utf8PercentEncodeString(tuple[0], isURLEncodedPercentEncode, true);
|
||||
const value = utf8PercentEncodeString(tuple[1], isURLEncodedPercentEncode, true);
|
||||
|
||||
if (i !== 0) {
|
||||
output += "&";
|
||||
}
|
||||
output += `${name}=${value}`;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
function strictlySplitByteSequence(buf, cp) {
|
||||
const list = [];
|
||||
let last = 0;
|
||||
let i = buf.indexOf(cp);
|
||||
while (i >= 0) {
|
||||
list.push(buf.slice(last, i));
|
||||
last = i + 1;
|
||||
i = buf.indexOf(cp, last);
|
||||
}
|
||||
if (last !== buf.length) {
|
||||
list.push(buf.slice(last));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
function replaceByteInByteSequence(buf, from, to) {
|
||||
let i = buf.indexOf(from);
|
||||
while (i >= 0) {
|
||||
buf[i] = to;
|
||||
i = buf.indexOf(from, i + 1);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
parseUrlencodedString,
|
||||
serializeUrlencoded
|
||||
};
|
||||
190
node_modules/jsdom/node_modules/whatwg-url/lib/utils.js
generated
vendored
Normal file
190
node_modules/jsdom/node_modules/whatwg-url/lib/utils.js
generated
vendored
Normal file
|
|
@ -0,0 +1,190 @@
|
|||
"use strict";
|
||||
|
||||
// Returns "Type(value) is Object" in ES terminology.
|
||||
function isObject(value) {
|
||||
return (typeof value === "object" && value !== null) || typeof value === "function";
|
||||
}
|
||||
|
||||
const hasOwn = Function.prototype.call.bind(Object.prototype.hasOwnProperty);
|
||||
|
||||
// Like `Object.assign`, but using `[[GetOwnProperty]]` and `[[DefineOwnProperty]]`
|
||||
// instead of `[[Get]]` and `[[Set]]` and only allowing objects
|
||||
function define(target, source) {
|
||||
for (const key of Reflect.ownKeys(source)) {
|
||||
const descriptor = Reflect.getOwnPropertyDescriptor(source, key);
|
||||
if (descriptor && !Reflect.defineProperty(target, key, descriptor)) {
|
||||
throw new TypeError(`Cannot redefine property: ${String(key)}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function newObjectInRealm(globalObject, object) {
|
||||
const ctorRegistry = initCtorRegistry(globalObject);
|
||||
return Object.defineProperties(
|
||||
Object.create(ctorRegistry["%Object.prototype%"]),
|
||||
Object.getOwnPropertyDescriptors(object)
|
||||
);
|
||||
}
|
||||
|
||||
const wrapperSymbol = Symbol("wrapper");
|
||||
const implSymbol = Symbol("impl");
|
||||
const sameObjectCaches = Symbol("SameObject caches");
|
||||
const ctorRegistrySymbol = Symbol.for("[webidl2js] constructor registry");
|
||||
|
||||
const AsyncIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf(async function* () {}).prototype);
|
||||
|
||||
function initCtorRegistry(globalObject) {
|
||||
if (hasOwn(globalObject, ctorRegistrySymbol)) {
|
||||
return globalObject[ctorRegistrySymbol];
|
||||
}
|
||||
|
||||
const ctorRegistry = Object.create(null);
|
||||
|
||||
// In addition to registering all the WebIDL2JS-generated types in the constructor registry,
|
||||
// we also register a few intrinsics that we make use of in generated code, since they are not
|
||||
// easy to grab from the globalObject variable.
|
||||
ctorRegistry["%Object.prototype%"] = globalObject.Object.prototype;
|
||||
ctorRegistry["%IteratorPrototype%"] = Object.getPrototypeOf(
|
||||
Object.getPrototypeOf(new globalObject.Array()[Symbol.iterator]())
|
||||
);
|
||||
|
||||
try {
|
||||
ctorRegistry["%AsyncIteratorPrototype%"] = Object.getPrototypeOf(
|
||||
Object.getPrototypeOf(
|
||||
globalObject.eval("(async function* () {})").prototype
|
||||
)
|
||||
);
|
||||
} catch {
|
||||
ctorRegistry["%AsyncIteratorPrototype%"] = AsyncIteratorPrototype;
|
||||
}
|
||||
|
||||
globalObject[ctorRegistrySymbol] = ctorRegistry;
|
||||
return ctorRegistry;
|
||||
}
|
||||
|
||||
function getSameObject(wrapper, prop, creator) {
|
||||
if (!wrapper[sameObjectCaches]) {
|
||||
wrapper[sameObjectCaches] = Object.create(null);
|
||||
}
|
||||
|
||||
if (prop in wrapper[sameObjectCaches]) {
|
||||
return wrapper[sameObjectCaches][prop];
|
||||
}
|
||||
|
||||
wrapper[sameObjectCaches][prop] = creator();
|
||||
return wrapper[sameObjectCaches][prop];
|
||||
}
|
||||
|
||||
function wrapperForImpl(impl) {
|
||||
return impl ? impl[wrapperSymbol] : null;
|
||||
}
|
||||
|
||||
function implForWrapper(wrapper) {
|
||||
return wrapper ? wrapper[implSymbol] : null;
|
||||
}
|
||||
|
||||
function tryWrapperForImpl(impl) {
|
||||
const wrapper = wrapperForImpl(impl);
|
||||
return wrapper ? wrapper : impl;
|
||||
}
|
||||
|
||||
function tryImplForWrapper(wrapper) {
|
||||
const impl = implForWrapper(wrapper);
|
||||
return impl ? impl : wrapper;
|
||||
}
|
||||
|
||||
const iterInternalSymbol = Symbol("internal");
|
||||
|
||||
function isArrayIndexPropName(P) {
|
||||
if (typeof P !== "string") {
|
||||
return false;
|
||||
}
|
||||
const i = P >>> 0;
|
||||
if (i === 2 ** 32 - 1) {
|
||||
return false;
|
||||
}
|
||||
const s = `${i}`;
|
||||
if (P !== s) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const byteLengthGetter =
|
||||
Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get;
|
||||
function isArrayBuffer(value) {
|
||||
try {
|
||||
byteLengthGetter.call(value);
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function iteratorResult([key, value], kind) {
|
||||
let result;
|
||||
switch (kind) {
|
||||
case "key":
|
||||
result = key;
|
||||
break;
|
||||
case "value":
|
||||
result = value;
|
||||
break;
|
||||
case "key+value":
|
||||
result = [key, value];
|
||||
break;
|
||||
}
|
||||
return { value: result, done: false };
|
||||
}
|
||||
|
||||
const supportsPropertyIndex = Symbol("supports property index");
|
||||
const supportedPropertyIndices = Symbol("supported property indices");
|
||||
const supportsPropertyName = Symbol("supports property name");
|
||||
const supportedPropertyNames = Symbol("supported property names");
|
||||
const indexedGet = Symbol("indexed property get");
|
||||
const indexedSetNew = Symbol("indexed property set new");
|
||||
const indexedSetExisting = Symbol("indexed property set existing");
|
||||
const namedGet = Symbol("named property get");
|
||||
const namedSetNew = Symbol("named property set new");
|
||||
const namedSetExisting = Symbol("named property set existing");
|
||||
const namedDelete = Symbol("named property delete");
|
||||
|
||||
const asyncIteratorNext = Symbol("async iterator get the next iteration result");
|
||||
const asyncIteratorReturn = Symbol("async iterator return steps");
|
||||
const asyncIteratorInit = Symbol("async iterator initialization steps");
|
||||
const asyncIteratorEOI = Symbol("async iterator end of iteration");
|
||||
|
||||
module.exports = exports = {
|
||||
isObject,
|
||||
hasOwn,
|
||||
define,
|
||||
newObjectInRealm,
|
||||
wrapperSymbol,
|
||||
implSymbol,
|
||||
getSameObject,
|
||||
ctorRegistrySymbol,
|
||||
initCtorRegistry,
|
||||
wrapperForImpl,
|
||||
implForWrapper,
|
||||
tryWrapperForImpl,
|
||||
tryImplForWrapper,
|
||||
iterInternalSymbol,
|
||||
isArrayBuffer,
|
||||
isArrayIndexPropName,
|
||||
supportsPropertyIndex,
|
||||
supportedPropertyIndices,
|
||||
supportsPropertyName,
|
||||
supportedPropertyNames,
|
||||
indexedGet,
|
||||
indexedSetNew,
|
||||
indexedSetExisting,
|
||||
namedGet,
|
||||
namedSetNew,
|
||||
namedSetExisting,
|
||||
namedDelete,
|
||||
asyncIteratorNext,
|
||||
asyncIteratorReturn,
|
||||
asyncIteratorInit,
|
||||
asyncIteratorEOI,
|
||||
iteratorResult
|
||||
};
|
||||
53
node_modules/jsdom/node_modules/whatwg-url/package.json
generated
vendored
Normal file
53
node_modules/jsdom/node_modules/whatwg-url/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
"name": "whatwg-url",
|
||||
"version": "14.2.0",
|
||||
"description": "An implementation of the WHATWG URL Standard's URL API and parsing machinery",
|
||||
"main": "index.js",
|
||||
"files": [
|
||||
"index.js",
|
||||
"webidl2js-wrapper.js",
|
||||
"lib/*.js"
|
||||
],
|
||||
"author": "Sebastian Mayr <github@smayr.name>",
|
||||
"license": "MIT",
|
||||
"repository": "jsdom/whatwg-url",
|
||||
"dependencies": {
|
||||
"tr46": "^5.1.0",
|
||||
"webidl-conversions": "^7.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@domenic/eslint-config": "^4.0.1",
|
||||
"benchmark": "^2.1.4",
|
||||
"c8": "^10.1.3",
|
||||
"esbuild": "^0.25.1",
|
||||
"eslint": "^9.22.0",
|
||||
"globals": "^16.0.0",
|
||||
"webidl2js": "^18.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"scripts": {
|
||||
"coverage": "c8 node --test --experimental-test-coverage test/*.js",
|
||||
"lint": "eslint",
|
||||
"prepare": "node scripts/transform.js",
|
||||
"pretest": "node scripts/get-latest-platform-tests.js && node scripts/transform.js",
|
||||
"build-live-viewer": "esbuild --bundle --format=esm --sourcemap --outfile=live-viewer/whatwg-url.mjs index.js",
|
||||
"test": "node --test test/*.js",
|
||||
"bench": "node scripts/benchmark.js"
|
||||
},
|
||||
"c8": {
|
||||
"reporter": [
|
||||
"text",
|
||||
"html"
|
||||
],
|
||||
"exclude": [
|
||||
"lib/Function.js",
|
||||
"lib/URL.js",
|
||||
"lib/URLSearchParams.js",
|
||||
"lib/utils.js",
|
||||
"scripts/",
|
||||
"test/"
|
||||
]
|
||||
}
|
||||
}
|
||||
7
node_modules/jsdom/node_modules/whatwg-url/webidl2js-wrapper.js
generated
vendored
Normal file
7
node_modules/jsdom/node_modules/whatwg-url/webidl2js-wrapper.js
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
"use strict";
|
||||
|
||||
const URL = require("./lib/URL");
|
||||
const URLSearchParams = require("./lib/URLSearchParams");
|
||||
|
||||
exports.URL = URL;
|
||||
exports.URLSearchParams = URLSearchParams;
|
||||
Loading…
Add table
Add a link
Reference in a new issue