From 3d1cd02f27518f1a04374c7c8320cd5d82ede6e9 Mon Sep 17 00:00:00 2001 From: Minteck Date: Thu, 23 Feb 2023 19:34:56 +0100 Subject: Updated 40 files, added 37 files, deleted 1103 files and renamed 3905 files (automated) --- school/node_modules/url-parse/LICENSE | 22 - school/node_modules/url-parse/README.md | 153 ----- school/node_modules/url-parse/dist/url-parse.js | 755 --------------------- .../node_modules/url-parse/dist/url-parse.min.js | 1 - .../url-parse/dist/url-parse.min.js.map | 1 - school/node_modules/url-parse/index.js | 589 ---------------- school/node_modules/url-parse/package.json | 49 -- 7 files changed, 1570 deletions(-) delete mode 100644 school/node_modules/url-parse/LICENSE delete mode 100644 school/node_modules/url-parse/README.md delete mode 100644 school/node_modules/url-parse/dist/url-parse.js delete mode 100644 school/node_modules/url-parse/dist/url-parse.min.js delete mode 100644 school/node_modules/url-parse/dist/url-parse.min.js.map delete mode 100644 school/node_modules/url-parse/index.js delete mode 100644 school/node_modules/url-parse/package.json (limited to 'school/node_modules/url-parse') diff --git a/school/node_modules/url-parse/LICENSE b/school/node_modules/url-parse/LICENSE deleted file mode 100644 index 6dc9316..0000000 --- a/school/node_modules/url-parse/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 Unshift.io, Arnout Kazemier, the 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. - diff --git a/school/node_modules/url-parse/README.md b/school/node_modules/url-parse/README.md deleted file mode 100644 index e5bf8d7..0000000 --- a/school/node_modules/url-parse/README.md +++ /dev/null @@ -1,153 +0,0 @@ -# url-parse - -[![Version npm](https://img.shields.io/npm/v/url-parse.svg?style=flat-square)](https://www.npmjs.com/package/url-parse)[![Build Status](https://img.shields.io/github/workflow/status/unshiftio/url-parse/CI/master?label=CI&style=flat-square)](https://github.com/unshiftio/url-parse/actions?query=workflow%3ACI+branch%3Amaster)[![Coverage Status](https://img.shields.io/coveralls/unshiftio/url-parse/master.svg?style=flat-square)](https://coveralls.io/r/unshiftio/url-parse?branch=master) - -[![Sauce Test Status](https://saucelabs.com/browser-matrix/url-parse.svg)](https://saucelabs.com/u/url-parse) - -**`url-parse` was created in 2014 when the WHATWG URL API was not available in -Node.js and the `URL` interface was supported only in some browsers. Today this -is no longer true. The `URL` interface is available in all supported Node.js -release lines and basically all browsers. Consider using it for better security -and accuracy.** - -The `url-parse` method exposes two different API interfaces. The -[`url`](https://nodejs.org/api/url.html) interface that you know from Node.js -and the new [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) -interface that is available in the latest browsers. - -In version `0.1` we moved from a DOM based parsing solution, using the `` -element, to a full Regular Expression solution. The main reason for this was -to make the URL parser available in different JavaScript environments as you -don't always have access to the DOM. An example of such environment is the -[`Worker`](https://developer.mozilla.org/en/docs/Web/API/Worker) interface. -The RegExp based solution didn't work well as it required a lot of lookups -causing major problems in FireFox. In version `1.0.0` we ditched the RegExp -based solution in favor of a pure string parsing solution which chops up the -URL into smaller pieces. This module still has a really small footprint as it -has been designed to be used on the client side. - -In addition to URL parsing we also expose the bundled `querystringify` module. - -## Installation - -This module is designed to be used using either browserify or Node.js it's -released in the public npm registry and can be installed using: - -``` -npm install url-parse -``` - -## Usage - -All examples assume that this library is bootstrapped using: - -```js -'use strict'; - -var Url = require('url-parse'); -``` - -To parse an URL simply call the `URL` method with the URL that needs to be -transformed into an object. - -```js -var url = new Url('https://github.com/foo/bar'); -``` - -The `new` keyword is optional but it will save you an extra function invocation. -The constructor takes the following arguments: - -- `url` (`String`): A string representing an absolute or relative URL. -- `baseURL` (`Object` | `String`): An object or string representing - the base URL to use in case `url` is a relative URL. This argument is - optional and defaults to [`location`](https://developer.mozilla.org/en-US/docs/Web/API/Location) - in the browser. -- `parser` (`Boolean` | `Function`): This argument is optional and specifies - how to parse the query string. By default it is `false` so the query string - is not parsed. If you pass `true` the query string is parsed using the - embedded `querystringify` module. If you pass a function the query string - will be parsed using this function. - -As said above we also support the Node.js interface so you can also use the -library in this way: - -```js -'use strict'; - -var parse = require('url-parse') - , url = parse('https://github.com/foo/bar', true); -``` - -The returned `url` instance contains the following properties: - -- `protocol`: The protocol scheme of the URL (e.g. `http:`). -- `slashes`: A boolean which indicates whether the `protocol` is followed by two - forward slashes (`//`). -- `auth`: Authentication information portion (e.g. `username:password`). -- `username`: Username of basic authentication. -- `password`: Password of basic authentication. -- `host`: Host name with port number. The hostname might be invalid. -- `hostname`: Host name without port number. This might be an invalid hostname. -- `port`: Optional port number. -- `pathname`: URL path. -- `query`: Parsed object containing query string, unless parsing is set to false. -- `hash`: The "fragment" portion of the URL including the pound-sign (`#`). -- `href`: The full URL. -- `origin`: The origin of the URL. - -Note that when `url-parse` is used in a browser environment, it will default to -using the browser's current window location as the base URL when parsing all -inputs. To parse an input independently of the browser's current URL (e.g. for -functionality parity with the library in a Node environment), pass an empty -location object as the second parameter: - -```js -var parse = require('url-parse'); -parse('hostname', {}); -``` - -### Url.set(key, value) - -A simple helper function to change parts of the URL and propagating it through -all properties. When you set a new `host` you want the same value to be applied -to `port` if has a different port number, `hostname` so it has a correct name -again and `href` so you have a complete URL. - -```js -var parsed = parse('http://google.com/parse-things'); - -parsed.set('hostname', 'yahoo.com'); -console.log(parsed.href); // http://yahoo.com/parse-things -``` - -It's aware of default ports so you cannot set a port 80 on an URL which has -`http` as protocol. - -### Url.toString() - -The returned `url` object comes with a custom `toString` method which will -generate a full URL again when called. The method accepts an extra function -which will stringify the query string for you. If you don't supply a function we -will use our default method. - -```js -var location = url.toString(); // http://example.com/whatever/?qs=32 -``` - -You would rarely need to use this method as the full URL is also available as -`href` property. If you are using the `URL.set` method to make changes, this -will automatically update. - -## Testing - -The testing of this module is done in 3 different ways: - -1. We have unit tests that run under Node.js. You can run these tests with the - `npm test` command. -2. Code coverage can be run manually using `npm run coverage`. -3. For browser testing we use Sauce Labs and `zuul`. You can run browser tests - using the `npm run test-browser` command. - -## License - -[MIT](LICENSE) diff --git a/school/node_modules/url-parse/dist/url-parse.js b/school/node_modules/url-parse/dist/url-parse.js deleted file mode 100644 index e989193..0000000 --- a/school/node_modules/url-parse/dist/url-parse.js +++ /dev/null @@ -1,755 +0,0 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.URLParse = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i= 2) { - rest = rest.slice(2); - } - } else if (isSpecial(protocol)) { - rest = match[4]; - } else if (protocol) { - if (forwardSlashes) { - rest = rest.slice(2); - } - } else if (slashesCount >= 2 && isSpecial(location.protocol)) { - rest = match[4]; - } - - return { - protocol: protocol, - slashes: forwardSlashes || isSpecial(protocol), - slashesCount: slashesCount, - rest: rest - }; -} - -/** - * Resolve a relative URL pathname against a base URL pathname. - * - * @param {String} relative Pathname of the relative URL. - * @param {String} base Pathname of the base URL. - * @return {String} Resolved pathname. - * @private - */ -function resolve(relative, base) { - if (relative === '') return base; - - var path = (base || '/').split('/').slice(0, -1).concat(relative.split('/')) - , i = path.length - , last = path[i - 1] - , unshift = false - , up = 0; - - while (i--) { - if (path[i] === '.') { - path.splice(i, 1); - } else if (path[i] === '..') { - path.splice(i, 1); - up++; - } else if (up) { - if (i === 0) unshift = true; - path.splice(i, 1); - up--; - } - } - - if (unshift) path.unshift(''); - if (last === '.' || last === '..') path.push(''); - - return path.join('/'); -} - -/** - * The actual URL instance. Instead of returning an object we've opted-in to - * create an actual constructor as it's much more memory efficient and - * faster and it pleases my OCD. - * - * It is worth noting that we should not use `URL` as class name to prevent - * clashes with the global URL instance that got introduced in browsers. - * - * @constructor - * @param {String} address URL we want to parse. - * @param {Object|String} [location] Location defaults for relative paths. - * @param {Boolean|Function} [parser] Parser for the query string. - * @private - */ -function Url(address, location, parser) { - address = trimLeft(address); - address = address.replace(CRHTLF, ''); - - if (!(this instanceof Url)) { - return new Url(address, location, parser); - } - - var relative, extracted, parse, instruction, index, key - , instructions = rules.slice() - , type = typeof location - , url = this - , i = 0; - - // - // The following if statements allows this module two have compatibility with - // 2 different API: - // - // 1. Node.js's `url.parse` api which accepts a URL, boolean as arguments - // where the boolean indicates that the query string should also be parsed. - // - // 2. The `URL` interface of the browser which accepts a URL, object as - // arguments. The supplied object will be used as default values / fall-back - // for relative paths. - // - if ('object' !== type && 'string' !== type) { - parser = location; - location = null; - } - - if (parser && 'function' !== typeof parser) parser = qs.parse; - - location = lolcation(location); - - // - // Extract protocol information before running the instructions. - // - extracted = extractProtocol(address || '', location); - relative = !extracted.protocol && !extracted.slashes; - url.slashes = extracted.slashes || relative && location.slashes; - url.protocol = extracted.protocol || location.protocol || ''; - address = extracted.rest; - - // - // When the authority component is absent the URL starts with a path - // component. - // - if ( - extracted.protocol === 'file:' && ( - extracted.slashesCount !== 2 || windowsDriveLetter.test(address)) || - (!extracted.slashes && - (extracted.protocol || - extracted.slashesCount < 2 || - !isSpecial(url.protocol))) - ) { - instructions[3] = [/(.*)/, 'pathname']; - } - - for (; i < instructions.length; i++) { - instruction = instructions[i]; - - if (typeof instruction === 'function') { - address = instruction(address, url); - continue; - } - - parse = instruction[0]; - key = instruction[1]; - - if (parse !== parse) { - url[key] = address; - } else if ('string' === typeof parse) { - index = parse === '@' - ? address.lastIndexOf(parse) - : address.indexOf(parse); - - if (~index) { - if ('number' === typeof instruction[2]) { - url[key] = address.slice(0, index); - address = address.slice(index + instruction[2]); - } else { - url[key] = address.slice(index); - address = address.slice(0, index); - } - } - } else if ((index = parse.exec(address))) { - url[key] = index[1]; - address = address.slice(0, index.index); - } - - url[key] = url[key] || ( - relative && instruction[3] ? location[key] || '' : '' - ); - - // - // Hostname, host and protocol should be lowercased so they can be used to - // create a proper `origin`. - // - if (instruction[4]) url[key] = url[key].toLowerCase(); - } - - // - // Also parse the supplied query string in to an object. If we're supplied - // with a custom parser as function use that instead of the default build-in - // parser. - // - if (parser) url.query = parser(url.query); - - // - // If the URL is relative, resolve the pathname against the base URL. - // - if ( - relative - && location.slashes - && url.pathname.charAt(0) !== '/' - && (url.pathname !== '' || location.pathname !== '') - ) { - url.pathname = resolve(url.pathname, location.pathname); - } - - // - // Default to a / for pathname if none exists. This normalizes the URL - // to always have a / - // - if (url.pathname.charAt(0) !== '/' && isSpecial(url.protocol)) { - url.pathname = '/' + url.pathname; - } - - // - // We should not add port numbers if they are already the default port number - // for a given protocol. As the host also contains the port number we're going - // override it with the hostname which contains no port number. - // - if (!required(url.port, url.protocol)) { - url.host = url.hostname; - url.port = ''; - } - - // - // Parse down the `auth` for the username and password. - // - url.username = url.password = ''; - - if (url.auth) { - index = url.auth.indexOf(':'); - - if (~index) { - url.username = url.auth.slice(0, index); - url.username = encodeURIComponent(decodeURIComponent(url.username)); - - url.password = url.auth.slice(index + 1); - url.password = encodeURIComponent(decodeURIComponent(url.password)) - } else { - url.username = encodeURIComponent(decodeURIComponent(url.auth)); - } - - url.auth = url.password ? url.username +':'+ url.password : url.username; - } - - url.origin = url.protocol !== 'file:' && isSpecial(url.protocol) && url.host - ? url.protocol +'//'+ url.host - : 'null'; - - // - // The href is just the compiled result. - // - url.href = url.toString(); -} - -/** - * This is convenience method for changing properties in the URL instance to - * insure that they all propagate correctly. - * - * @param {String} part Property we need to adjust. - * @param {Mixed} value The newly assigned value. - * @param {Boolean|Function} fn When setting the query, it will be the function - * used to parse the query. - * When setting the protocol, double slash will be - * removed from the final url if it is true. - * @returns {URL} URL instance for chaining. - * @public - */ -function set(part, value, fn) { - var url = this; - - switch (part) { - case 'query': - if ('string' === typeof value && value.length) { - value = (fn || qs.parse)(value); - } - - url[part] = value; - break; - - case 'port': - url[part] = value; - - if (!required(value, url.protocol)) { - url.host = url.hostname; - url[part] = ''; - } else if (value) { - url.host = url.hostname +':'+ value; - } - - break; - - case 'hostname': - url[part] = value; - - if (url.port) value += ':'+ url.port; - url.host = value; - break; - - case 'host': - url[part] = value; - - if (port.test(value)) { - value = value.split(':'); - url.port = value.pop(); - url.hostname = value.join(':'); - } else { - url.hostname = value; - url.port = ''; - } - - break; - - case 'protocol': - url.protocol = value.toLowerCase(); - url.slashes = !fn; - break; - - case 'pathname': - case 'hash': - if (value) { - var char = part === 'pathname' ? '/' : '#'; - url[part] = value.charAt(0) !== char ? char + value : value; - } else { - url[part] = value; - } - break; - - case 'username': - case 'password': - url[part] = encodeURIComponent(value); - break; - - case 'auth': - var index = value.indexOf(':'); - - if (~index) { - url.username = value.slice(0, index); - url.username = encodeURIComponent(decodeURIComponent(url.username)); - - url.password = value.slice(index + 1); - url.password = encodeURIComponent(decodeURIComponent(url.password)); - } else { - url.username = encodeURIComponent(decodeURIComponent(value)); - } - } - - for (var i = 0; i < rules.length; i++) { - var ins = rules[i]; - - if (ins[4]) url[ins[1]] = url[ins[1]].toLowerCase(); - } - - url.auth = url.password ? url.username +':'+ url.password : url.username; - - url.origin = url.protocol !== 'file:' && isSpecial(url.protocol) && url.host - ? url.protocol +'//'+ url.host - : 'null'; - - url.href = url.toString(); - - return url; -} - -/** - * Transform the properties back in to a valid and full URL string. - * - * @param {Function} stringify Optional query stringify function. - * @returns {String} Compiled version of the URL. - * @public - */ -function toString(stringify) { - if (!stringify || 'function' !== typeof stringify) stringify = qs.stringify; - - var query - , url = this - , host = url.host - , protocol = url.protocol; - - if (protocol && protocol.charAt(protocol.length - 1) !== ':') protocol += ':'; - - var result = - protocol + - ((url.protocol && url.slashes) || isSpecial(url.protocol) ? '//' : ''); - - if (url.username) { - result += url.username; - if (url.password) result += ':'+ url.password; - result += '@'; - } else if (url.password) { - result += ':'+ url.password; - result += '@'; - } else if ( - url.protocol !== 'file:' && - isSpecial(url.protocol) && - !host && - url.pathname !== '/' - ) { - // - // Add back the empty userinfo, otherwise the original invalid URL - // might be transformed into a valid one with `url.pathname` as host. - // - result += '@'; - } - - // - // Trailing colon is removed from `url.host` when it is parsed. If it still - // ends with a colon, then add back the trailing colon that was removed. This - // prevents an invalid URL from being transformed into a valid one. - // - if (host[host.length - 1] === ':' || (port.test(url.hostname) && !url.port)) { - host += ':'; - } - - result += host + url.pathname; - - query = 'object' === typeof url.query ? stringify(url.query) : url.query; - if (query) result += '?' !== query.charAt(0) ? '?'+ query : query; - - if (url.hash) result += url.hash; - - return result; -} - -Url.prototype = { set: set, toString: toString }; - -// -// Expose the URL parser and some additional properties that might be useful for -// others or testing. -// -Url.extractProtocol = extractProtocol; -Url.location = lolcation; -Url.trimLeft = trimLeft; -Url.qs = qs; - -module.exports = Url; - -}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"querystringify":2,"requires-port":3}],2:[function(require,module,exports){ -'use strict'; - -var has = Object.prototype.hasOwnProperty - , undef; - -/** - * Decode a URI encoded string. - * - * @param {String} input The URI encoded string. - * @returns {String|Null} The decoded string. - * @api private - */ -function decode(input) { - try { - return decodeURIComponent(input.replace(/\+/g, ' ')); - } catch (e) { - return null; - } -} - -/** - * Attempts to encode a given input. - * - * @param {String} input The string that needs to be encoded. - * @returns {String|Null} The encoded string. - * @api private - */ -function encode(input) { - try { - return encodeURIComponent(input); - } catch (e) { - return null; - } -} - -/** - * Simple query string parser. - * - * @param {String} query The query string that needs to be parsed. - * @returns {Object} - * @api public - */ -function querystring(query) { - var parser = /([^=?#&]+)=?([^&]*)/g - , result = {} - , part; - - while (part = parser.exec(query)) { - var key = decode(part[1]) - , value = decode(part[2]); - - // - // Prevent overriding of existing properties. This ensures that build-in - // methods like `toString` or __proto__ are not overriden by malicious - // querystrings. - // - // In the case if failed decoding, we want to omit the key/value pairs - // from the result. - // - if (key === null || value === null || key in result) continue; - result[key] = value; - } - - return result; -} - -/** - * Transform a query string to an object. - * - * @param {Object} obj Object that should be transformed. - * @param {String} prefix Optional prefix. - * @returns {String} - * @api public - */ -function querystringify(obj, prefix) { - prefix = prefix || ''; - - var pairs = [] - , value - , key; - - // - // Optionally prefix with a '?' if needed - // - if ('string' !== typeof prefix) prefix = '?'; - - for (key in obj) { - if (has.call(obj, key)) { - value = obj[key]; - - // - // Edge cases where we actually want to encode the value to an empty - // string instead of the stringified value. - // - if (!value && (value === null || value === undef || isNaN(value))) { - value = ''; - } - - key = encode(key); - value = encode(value); - - // - // If we failed to encode the strings, we should bail out as we don't - // want to add invalid strings to the query. - // - if (key === null || value === null) continue; - pairs.push(key +'='+ value); - } - } - - return pairs.length ? prefix + pairs.join('&') : ''; -} - -// -// Expose the module. -// -exports.stringify = querystringify; -exports.parse = querystring; - -},{}],3:[function(require,module,exports){ -'use strict'; - -/** - * Check if we're required to add a port number. - * - * @see https://url.spec.whatwg.org/#default-port - * @param {Number|String} port Port number we need to check - * @param {String} protocol Protocol we need to check against. - * @returns {Boolean} Is it a default port for the given protocol - * @api private - */ -module.exports = function required(port, protocol) { - protocol = protocol.split(':')[0]; - port = +port; - - if (!port) return false; - - switch (protocol) { - case 'http': - case 'ws': - return port !== 80; - - case 'https': - case 'wss': - return port !== 443; - - case 'ftp': - return port !== 21; - - case 'gopher': - return port !== 70; - - case 'file': - return false; - } - - return port !== 0; -}; - -},{}]},{},[1])(1) -}); diff --git a/school/node_modules/url-parse/dist/url-parse.min.js b/school/node_modules/url-parse/dist/url-parse.min.js deleted file mode 100644 index f0b3b4c..0000000 --- a/school/node_modules/url-parse/dist/url-parse.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).URLParse=e()}(function(){return function n(r,s,a){function i(o,e){if(!s[o]){if(!r[o]){var t="function"==typeof require&&require;if(!e&&t)return t(o,!0);if(p)return p(o,!0);throw(e=new Error("Cannot find module '"+o+"'")).code="MODULE_NOT_FOUND",e}t=s[o]={exports:{}},r[o][0].call(t.exports,function(e){return i(r[o][1][e]||e)},t,t.exports,n,r,s,a)}return s[o].exports}for(var p="function"==typeof require&&require,e=0;e= 2) { - rest = rest.slice(2); - } - } else if (isSpecial(protocol)) { - rest = match[4]; - } else if (protocol) { - if (forwardSlashes) { - rest = rest.slice(2); - } - } else if (slashesCount >= 2 && isSpecial(location.protocol)) { - rest = match[4]; - } - - return { - protocol: protocol, - slashes: forwardSlashes || isSpecial(protocol), - slashesCount: slashesCount, - rest: rest - }; -} - -/** - * Resolve a relative URL pathname against a base URL pathname. - * - * @param {String} relative Pathname of the relative URL. - * @param {String} base Pathname of the base URL. - * @return {String} Resolved pathname. - * @private - */ -function resolve(relative, base) { - if (relative === '') return base; - - var path = (base || '/').split('/').slice(0, -1).concat(relative.split('/')) - , i = path.length - , last = path[i - 1] - , unshift = false - , up = 0; - - while (i--) { - if (path[i] === '.') { - path.splice(i, 1); - } else if (path[i] === '..') { - path.splice(i, 1); - up++; - } else if (up) { - if (i === 0) unshift = true; - path.splice(i, 1); - up--; - } - } - - if (unshift) path.unshift(''); - if (last === '.' || last === '..') path.push(''); - - return path.join('/'); -} - -/** - * The actual URL instance. Instead of returning an object we've opted-in to - * create an actual constructor as it's much more memory efficient and - * faster and it pleases my OCD. - * - * It is worth noting that we should not use `URL` as class name to prevent - * clashes with the global URL instance that got introduced in browsers. - * - * @constructor - * @param {String} address URL we want to parse. - * @param {Object|String} [location] Location defaults for relative paths. - * @param {Boolean|Function} [parser] Parser for the query string. - * @private - */ -function Url(address, location, parser) { - address = trimLeft(address); - address = address.replace(CRHTLF, ''); - - if (!(this instanceof Url)) { - return new Url(address, location, parser); - } - - var relative, extracted, parse, instruction, index, key - , instructions = rules.slice() - , type = typeof location - , url = this - , i = 0; - - // - // The following if statements allows this module two have compatibility with - // 2 different API: - // - // 1. Node.js's `url.parse` api which accepts a URL, boolean as arguments - // where the boolean indicates that the query string should also be parsed. - // - // 2. The `URL` interface of the browser which accepts a URL, object as - // arguments. The supplied object will be used as default values / fall-back - // for relative paths. - // - if ('object' !== type && 'string' !== type) { - parser = location; - location = null; - } - - if (parser && 'function' !== typeof parser) parser = qs.parse; - - location = lolcation(location); - - // - // Extract protocol information before running the instructions. - // - extracted = extractProtocol(address || '', location); - relative = !extracted.protocol && !extracted.slashes; - url.slashes = extracted.slashes || relative && location.slashes; - url.protocol = extracted.protocol || location.protocol || ''; - address = extracted.rest; - - // - // When the authority component is absent the URL starts with a path - // component. - // - if ( - extracted.protocol === 'file:' && ( - extracted.slashesCount !== 2 || windowsDriveLetter.test(address)) || - (!extracted.slashes && - (extracted.protocol || - extracted.slashesCount < 2 || - !isSpecial(url.protocol))) - ) { - instructions[3] = [/(.*)/, 'pathname']; - } - - for (; i < instructions.length; i++) { - instruction = instructions[i]; - - if (typeof instruction === 'function') { - address = instruction(address, url); - continue; - } - - parse = instruction[0]; - key = instruction[1]; - - if (parse !== parse) { - url[key] = address; - } else if ('string' === typeof parse) { - index = parse === '@' - ? address.lastIndexOf(parse) - : address.indexOf(parse); - - if (~index) { - if ('number' === typeof instruction[2]) { - url[key] = address.slice(0, index); - address = address.slice(index + instruction[2]); - } else { - url[key] = address.slice(index); - address = address.slice(0, index); - } - } - } else if ((index = parse.exec(address))) { - url[key] = index[1]; - address = address.slice(0, index.index); - } - - url[key] = url[key] || ( - relative && instruction[3] ? location[key] || '' : '' - ); - - // - // Hostname, host and protocol should be lowercased so they can be used to - // create a proper `origin`. - // - if (instruction[4]) url[key] = url[key].toLowerCase(); - } - - // - // Also parse the supplied query string in to an object. If we're supplied - // with a custom parser as function use that instead of the default build-in - // parser. - // - if (parser) url.query = parser(url.query); - - // - // If the URL is relative, resolve the pathname against the base URL. - // - if ( - relative - && location.slashes - && url.pathname.charAt(0) !== '/' - && (url.pathname !== '' || location.pathname !== '') - ) { - url.pathname = resolve(url.pathname, location.pathname); - } - - // - // Default to a / for pathname if none exists. This normalizes the URL - // to always have a / - // - if (url.pathname.charAt(0) !== '/' && isSpecial(url.protocol)) { - url.pathname = '/' + url.pathname; - } - - // - // We should not add port numbers if they are already the default port number - // for a given protocol. As the host also contains the port number we're going - // override it with the hostname which contains no port number. - // - if (!required(url.port, url.protocol)) { - url.host = url.hostname; - url.port = ''; - } - - // - // Parse down the `auth` for the username and password. - // - url.username = url.password = ''; - - if (url.auth) { - index = url.auth.indexOf(':'); - - if (~index) { - url.username = url.auth.slice(0, index); - url.username = encodeURIComponent(decodeURIComponent(url.username)); - - url.password = url.auth.slice(index + 1); - url.password = encodeURIComponent(decodeURIComponent(url.password)) - } else { - url.username = encodeURIComponent(decodeURIComponent(url.auth)); - } - - url.auth = url.password ? url.username +':'+ url.password : url.username; - } - - url.origin = url.protocol !== 'file:' && isSpecial(url.protocol) && url.host - ? url.protocol +'//'+ url.host - : 'null'; - - // - // The href is just the compiled result. - // - url.href = url.toString(); -} - -/** - * This is convenience method for changing properties in the URL instance to - * insure that they all propagate correctly. - * - * @param {String} part Property we need to adjust. - * @param {Mixed} value The newly assigned value. - * @param {Boolean|Function} fn When setting the query, it will be the function - * used to parse the query. - * When setting the protocol, double slash will be - * removed from the final url if it is true. - * @returns {URL} URL instance for chaining. - * @public - */ -function set(part, value, fn) { - var url = this; - - switch (part) { - case 'query': - if ('string' === typeof value && value.length) { - value = (fn || qs.parse)(value); - } - - url[part] = value; - break; - - case 'port': - url[part] = value; - - if (!required(value, url.protocol)) { - url.host = url.hostname; - url[part] = ''; - } else if (value) { - url.host = url.hostname +':'+ value; - } - - break; - - case 'hostname': - url[part] = value; - - if (url.port) value += ':'+ url.port; - url.host = value; - break; - - case 'host': - url[part] = value; - - if (port.test(value)) { - value = value.split(':'); - url.port = value.pop(); - url.hostname = value.join(':'); - } else { - url.hostname = value; - url.port = ''; - } - - break; - - case 'protocol': - url.protocol = value.toLowerCase(); - url.slashes = !fn; - break; - - case 'pathname': - case 'hash': - if (value) { - var char = part === 'pathname' ? '/' : '#'; - url[part] = value.charAt(0) !== char ? char + value : value; - } else { - url[part] = value; - } - break; - - case 'username': - case 'password': - url[part] = encodeURIComponent(value); - break; - - case 'auth': - var index = value.indexOf(':'); - - if (~index) { - url.username = value.slice(0, index); - url.username = encodeURIComponent(decodeURIComponent(url.username)); - - url.password = value.slice(index + 1); - url.password = encodeURIComponent(decodeURIComponent(url.password)); - } else { - url.username = encodeURIComponent(decodeURIComponent(value)); - } - } - - for (var i = 0; i < rules.length; i++) { - var ins = rules[i]; - - if (ins[4]) url[ins[1]] = url[ins[1]].toLowerCase(); - } - - url.auth = url.password ? url.username +':'+ url.password : url.username; - - url.origin = url.protocol !== 'file:' && isSpecial(url.protocol) && url.host - ? url.protocol +'//'+ url.host - : 'null'; - - url.href = url.toString(); - - return url; -} - -/** - * Transform the properties back in to a valid and full URL string. - * - * @param {Function} stringify Optional query stringify function. - * @returns {String} Compiled version of the URL. - * @public - */ -function toString(stringify) { - if (!stringify || 'function' !== typeof stringify) stringify = qs.stringify; - - var query - , url = this - , host = url.host - , protocol = url.protocol; - - if (protocol && protocol.charAt(protocol.length - 1) !== ':') protocol += ':'; - - var result = - protocol + - ((url.protocol && url.slashes) || isSpecial(url.protocol) ? '//' : ''); - - if (url.username) { - result += url.username; - if (url.password) result += ':'+ url.password; - result += '@'; - } else if (url.password) { - result += ':'+ url.password; - result += '@'; - } else if ( - url.protocol !== 'file:' && - isSpecial(url.protocol) && - !host && - url.pathname !== '/' - ) { - // - // Add back the empty userinfo, otherwise the original invalid URL - // might be transformed into a valid one with `url.pathname` as host. - // - result += '@'; - } - - // - // Trailing colon is removed from `url.host` when it is parsed. If it still - // ends with a colon, then add back the trailing colon that was removed. This - // prevents an invalid URL from being transformed into a valid one. - // - if (host[host.length - 1] === ':' || (port.test(url.hostname) && !url.port)) { - host += ':'; - } - - result += host + url.pathname; - - query = 'object' === typeof url.query ? stringify(url.query) : url.query; - if (query) result += '?' !== query.charAt(0) ? '?'+ query : query; - - if (url.hash) result += url.hash; - - return result; -} - -Url.prototype = { set: set, toString: toString }; - -// -// Expose the URL parser and some additional properties that might be useful for -// others or testing. -// -Url.extractProtocol = extractProtocol; -Url.location = lolcation; -Url.trimLeft = trimLeft; -Url.qs = qs; - -module.exports = Url; diff --git a/school/node_modules/url-parse/package.json b/school/node_modules/url-parse/package.json deleted file mode 100644 index 8d1bbbe..0000000 --- a/school/node_modules/url-parse/package.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "name": "url-parse", - "version": "1.5.10", - "description": "Small footprint URL parser that works seamlessly across Node.js and browser environments", - "main": "index.js", - "scripts": { - "browserify": "rm -rf dist && mkdir -p dist && browserify index.js -s URLParse -o dist/url-parse.js", - "minify": "uglifyjs dist/url-parse.js --source-map -cm -o dist/url-parse.min.js", - "test": "c8 --reporter=lcov --reporter=text mocha test/test.js", - "test-browser": "node test/browser.js", - "prepublishOnly": "npm run browserify && npm run minify", - "watch": "mocha --watch test/test.js" - }, - "files": [ - "index.js", - "dist" - ], - "repository": { - "type": "git", - "url": "https://github.com/unshiftio/url-parse.git" - }, - "keywords": [ - "URL", - "parser", - "uri", - "url", - "parse", - "query", - "string", - "querystring", - "stringify" - ], - "author": "Arnout Kazemier", - "license": "MIT", - "dependencies": { - "querystringify": "^2.1.1", - "requires-port": "^1.0.0" - }, - "devDependencies": { - "assume": "^2.2.0", - "browserify": "^17.0.0", - "c8": "^7.3.1", - "mocha": "^9.0.3", - "pre-commit": "^1.2.2", - "sauce-browsers": "^2.0.0", - "sauce-test": "^1.3.3", - "uglify-js": "^3.5.7" - } -} -- cgit