"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "dist/htmlminifier.js" between
html-minifier-3.6.0.tar.gz and html-minifier-4.0.0.tar.gz

About: html-minifier is a configurable Javascript-based HTML compressor/minifier (with Node.js support).


Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)
htmlminifier.js  (html-minifier-3.6.0):htmlminifier.js  (html-minifier-4.0.0)
/*! /*!
* HTMLMinifier v3.5.20 (https://kangax.github.io/html-minifier/) * HTMLMinifier v4.0.0 (https://kangax.github.io/html-minifier/)
* Copyright 2010-2018 Juriy "kangax" Zaytsev * Copyright 2010-2019 Juriy "kangax" Zaytsev
* Licensed under the MIT license * Licensed under the MIT license
*/ */
require=(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];retu rn o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeo f require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function (require,module,exports){ require=(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];retu rn o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeo f require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function (require,module,exports){
'use strict' 'use strict'
exports.byteLength = byteLength exports.byteLength = byteLength
exports.toByteArray = toByteArray exports.toByteArray = toByteArray
exports.fromByteArray = fromByteArray exports.fromByteArray = fromByteArray
skipping to change at line 165 skipping to change at line 165
} }
return parts.join('') return parts.join('')
} }
},{}],2:[function(require,module,exports){ },{}],2:[function(require,module,exports){
},{}],3:[function(require,module,exports){ },{}],3:[function(require,module,exports){
arguments[4][2][0].apply(exports,arguments) arguments[4][2][0].apply(exports,arguments)
},{"dup":2}],4:[function(require,module,exports){ },{"dup":2}],4:[function(require,module,exports){
(function (Buffer){
/*! /*!
* The buffer module from node.js, for the browser. * The buffer module from node.js, for the browser.
* *
* @author Feross Aboukhadijeh <https://feross.org> * @author Feross Aboukhadijeh <https://feross.org>
* @license MIT * @license MIT
*/ */
/* eslint-disable no-proto */ /* eslint-disable no-proto */
'use strict' 'use strict'
skipping to change at line 1943 skipping to change at line 1944
function isInstance (obj, type) { function isInstance (obj, type) {
return obj instanceof type || return obj instanceof type ||
(obj != null && obj.constructor != null && obj.constructor.name != null && (obj != null && obj.constructor != null && obj.constructor.name != null &&
obj.constructor.name === type.name) obj.constructor.name === type.name)
} }
function numberIsNaN (obj) { function numberIsNaN (obj) {
// For IE11 support // For IE11 support
return obj !== obj // eslint-disable-line no-self-compare return obj !== obj // eslint-disable-line no-self-compare
} }
},{"base64-js":1,"ieee754":105}],5:[function(require,module,exports){ }).call(this,require("buffer").Buffer)
},{"base64-js":1,"buffer":4,"ieee754":105}],5:[function(require,module,exports){
module.exports = { module.exports = {
"100": "Continue", "100": "Continue",
"101": "Switching Protocols", "101": "Switching Protocols",
"102": "Processing", "102": "Processing",
"200": "OK", "200": "OK",
"201": "Created", "201": "Created",
"202": "Accepted", "202": "Accepted",
"203": "Non-Authoritative Information", "203": "Non-Authoritative Information",
"204": "No Content", "204": "No Content",
"205": "Reset Content", "205": "Reset Content",
skipping to change at line 10918 skipping to change at line 10920
function toMetadata(asHash) { function toMetadata(asHash) {
return [asHash.line, asHash.column, asHash.source]; return [asHash.line, asHash.column, asHash.source];
} }
function track(maps, source, data) { function track(maps, source, data) {
maps[source] = new SourceMapConsumer(data); maps[source] = new SourceMapConsumer(data);
} }
module.exports = inputSourceMapTracker; module.exports = inputSourceMapTracker;
},{"source-map":154}],72:[function(require,module,exports){ },{"source-map":155}],72:[function(require,module,exports){
var path = require('path'); var path = require('path');
var url = require('url'); var url = require('url');
var isRemoteResource = require('../utils/is-remote-resource'); var isRemoteResource = require('../utils/is-remote-resource');
var hasProtocol = require('../utils/has-protocol'); var hasProtocol = require('../utils/has-protocol');
var HTTP_PROTOCOL = 'http:'; var HTTP_PROTOCOL = 'http:';
function isAllowedResource(uri, isRemote, rules) { function isAllowedResource(uri, isRemote, rules) {
var match; var match;
skipping to change at line 11201 skipping to change at line 11203
} }
errorHandled = true; errorHandled = true;
callback('timeout', null); callback('timeout', null);
}) })
.setTimeout(inlineTimeout); .setTimeout(inlineTimeout);
} }
module.exports = loadRemoteResource; module.exports = loadRemoteResource;
},{"../utils/is-http-resource":90,"../utils/is-https-resource":91,"../utils/over ride":95,"http":155,"https":104,"url":162}],75:[function(require,module,exports) { },{"../utils/is-http-resource":90,"../utils/is-https-resource":91,"../utils/over ride":95,"http":156,"https":104,"url":162}],75:[function(require,module,exports) {
var DATA_URI_PATTERN = /^data:(\S*?)?(;charset=[^;]+)?(;[^,]+?)?,(.+)/; var DATA_URI_PATTERN = /^data:(\S*?)?(;charset=[^;]+)?(;[^,]+?)?,(.+)/;
function matchDataUri(uri) { function matchDataUri(uri) {
return DATA_URI_PATTERN.exec(uri); return DATA_URI_PATTERN.exec(uri);
} }
module.exports = matchDataUri; module.exports = matchDataUri;
},{}],76:[function(require,module,exports){ },{}],76:[function(require,module,exports){
var UNIX_SEPARATOR = '/'; var UNIX_SEPARATOR = '/';
skipping to change at line 13108 skipping to change at line 13110
return { return {
sourceMap: serializeContext.outputMap, sourceMap: serializeContext.outputMap,
styles: serializeContext.output.join('') styles: serializeContext.output.join('')
}; };
} }
module.exports = serializeStylesAndSourceMap; module.exports = serializeStylesAndSourceMap;
}).call(this,require('_process')) }).call(this,require('_process'))
},{"../utils/is-remote-resource":93,"./helpers":97,"_process":112,"source-map":1 54}],101:[function(require,module,exports){ },{"../utils/is-remote-resource":93,"./helpers":97,"_process":112,"source-map":1 55}],101:[function(require,module,exports){
(function (Buffer){ (function (Buffer){
// Copyright Joyent, Inc. and other Node contributors. // Copyright Joyent, Inc. and other Node contributors.
// //
// Permission is hereby granted, free of charge, to any person obtaining a // Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the // copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including // "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish, // without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit // 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 // persons to whom the Software is furnished to do so, subject to the
// following conditions: // following conditions:
skipping to change at line 14126 skipping to change at line 14128
} }
if (!params.protocol) { if (!params.protocol) {
params.protocol = 'https:' params.protocol = 'https:'
} }
if (params.protocol !== 'https:') { if (params.protocol !== 'https:') {
throw new Error('Protocol "' + params.protocol + '" not supported. Expected "https:"') throw new Error('Protocol "' + params.protocol + '" not supported. Expected "https:"')
} }
return params return params
} }
},{"http":155,"url":162}],105:[function(require,module,exports){ },{"http":156,"url":162}],105:[function(require,module,exports){
exports.read = function (buffer, offset, isLE, mLen, nBytes) { exports.read = function (buffer, offset, isLE, mLen, nBytes) {
var e, m var e, m
var eLen = (nBytes * 8) - mLen - 1 var eLen = (nBytes * 8) - mLen - 1
var eMax = (1 << eLen) - 1 var eMax = (1 << eLen) - 1
var eBias = eMax >> 1 var eBias = eMax >> 1
var nBits = -7 var nBits = -7
var i = isLE ? (nBytes - 1) : 0 var i = isLE ? (nBytes - 1) : 0
var d = isLE ? -1 : 1 var d = isLE ? -1 : 1
var s = buffer[offset + i] var s = buffer[offset + i]
skipping to change at line 16771 skipping to change at line 16773
} }
} }
function indexOf(xs, x) { function indexOf(xs, x) {
for (var i = 0, l = xs.length; i < l; i++) { for (var i = 0, l = xs.length; i < l; i++) {
if (xs[i] === x) return i; if (xs[i] === x) return i;
} }
return -1; return -1;
} }
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"./_stream_duplex":117,"./internal/streams/BufferList":122,"./internal/stream s/destroy":123,"./internal/streams/stream":124,"_process":112,"core-util-is":101 ,"events":102,"inherits":106,"isarray":108,"process-nextick-args":111,"safe-buff er":143,"string_decoder/":159,"util":2}],120:[function(require,module,exports){ },{"./_stream_duplex":117,"./internal/streams/BufferList":122,"./internal/stream s/destroy":123,"./internal/streams/stream":124,"_process":112,"core-util-is":101 ,"events":102,"inherits":106,"isarray":108,"process-nextick-args":111,"safe-buff er":144,"string_decoder/":125,"util":2}],120:[function(require,module,exports){
// Copyright Joyent, Inc. and other Node contributors. // Copyright Joyent, Inc. and other Node contributors.
// //
// Permission is hereby granted, free of charge, to any person obtaining a // Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the // copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including // "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish, // without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit // 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 // persons to whom the Software is furnished to do so, subject to the
// following conditions: // following conditions:
// //
skipping to change at line 17676 skipping to change at line 17678
} }
}); });
Writable.prototype.destroy = destroyImpl.destroy; Writable.prototype.destroy = destroyImpl.destroy;
Writable.prototype._undestroy = destroyImpl.undestroy; Writable.prototype._undestroy = destroyImpl.undestroy;
Writable.prototype._destroy = function (err, cb) { Writable.prototype._destroy = function (err, cb) {
this.end(); this.end();
cb(err); cb(err);
}; };
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},requi re("timers").setImmediate) }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},requi re("timers").setImmediate)
},{"./_stream_duplex":117,"./internal/streams/destroy":123,"./internal/streams/s tream":124,"_process":112,"core-util-is":101,"inherits":106,"process-nextick-arg s":111,"safe-buffer":143,"timers":160,"util-deprecate":164}],122:[function(requi re,module,exports){ },{"./_stream_duplex":117,"./internal/streams/destroy":123,"./internal/streams/s tream":124,"_process":112,"core-util-is":101,"inherits":106,"process-nextick-arg s":111,"safe-buffer":144,"timers":160,"util-deprecate":164}],122:[function(requi re,module,exports){
'use strict'; 'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons tructor)) { throw new TypeError("Cannot call a class as a function"); } } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons tructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Buffer = require('safe-buffer').Buffer; var Buffer = require('safe-buffer').Buffer;
var util = require('util'); var util = require('util');
function copyBuffer(src, target, offset) { function copyBuffer(src, target, offset) {
src.copy(target, offset); src.copy(target, offset);
} }
skipping to change at line 17756 skipping to change at line 17758
return BufferList; return BufferList;
}(); }();
if (util && util.inspect && util.inspect.custom) { if (util && util.inspect && util.inspect.custom) {
module.exports.prototype[util.inspect.custom] = function () { module.exports.prototype[util.inspect.custom] = function () {
var obj = util.inspect({ length: this.length }); var obj = util.inspect({ length: this.length });
return this.constructor.name + ' ' + obj; return this.constructor.name + ' ' + obj;
}; };
} }
},{"safe-buffer":143,"util":2}],123:[function(require,module,exports){ },{"safe-buffer":144,"util":2}],123:[function(require,module,exports){
'use strict'; 'use strict';
/*<replacement>*/ /*<replacement>*/
var pna = require('process-nextick-args'); var pna = require('process-nextick-args');
/*</replacement>*/ /*</replacement>*/
// undocumented cb() API, needed for core, not for public API // undocumented cb() API, needed for core, not for public API
function destroy(err, cb) { function destroy(err, cb) {
var _this = this; var _this = this;
skipping to change at line 17835 skipping to change at line 17837
} }
module.exports = { module.exports = {
destroy: destroy, destroy: destroy,
undestroy: undestroy undestroy: undestroy
}; };
},{"process-nextick-args":111}],124:[function(require,module,exports){ },{"process-nextick-args":111}],124:[function(require,module,exports){
module.exports = require('events').EventEmitter; module.exports = require('events').EventEmitter;
},{"events":102}],125:[function(require,module,exports){ },{"events":102}],125:[function(require,module,exports){
exports = module.exports = require('./lib/_stream_readable.js'); // Copyright Joyent, Inc. and other Node contributors.
exports.Stream = exports; //
exports.Readable = exports; // Permission is hereby granted, free of charge, to any person obtaining a
exports.Writable = require('./lib/_stream_writable.js'); // copy of this software and associated documentation files (the
exports.Duplex = require('./lib/_stream_duplex.js'); // "Software"), to deal in the Software without restriction, including
exports.Transform = require('./lib/_stream_transform.js'); // without limitation the rights to use, copy, modify, merge, publish,
exports.PassThrough = require('./lib/_stream_passthrough.js'); // 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
},{"./lib/_stream_duplex.js":117,"./lib/_stream_passthrough.js":118,"./lib/_stre // following conditions:
am_readable.js":119,"./lib/_stream_transform.js":120,"./lib/_stream_writable.js" //
:121}],126:[function(require,module,exports){ // The above copyright notice and this permission notice shall be included
"use strict"; // 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.
module.exports = 'use strict';
{
// Output
ABSOLUTE: "absolute",
PATH_RELATIVE: "pathRelative",
ROOT_RELATIVE: "rootRelative",
SHORTEST: "shortest"
};
},{}],127:[function(require,module,exports){ /*<replacement>*/
"use strict";
var constants = require("./constants"); var Buffer = require('safe-buffer').Buffer;
/*</replacement>*/
function formatAuth(urlObj, options) var isEncoding = Buffer.isEncoding || function (encoding) {
{ encoding = '' + encoding;
if (urlObj.auth && !options.removeAuth && (urlObj.extra.relation.maximumH switch (encoding && encoding.toLowerCase()) {
ost || options.output===constants.ABSOLUTE)) case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64'
{ :case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
return urlObj.auth + "@"; return true;
} default:
return false;
}
};
return ""; function _normalizeEncoding(enc) {
} if (!enc) return 'utf8';
var retried;
while (true) {
switch (enc) {
case 'utf8':
case 'utf-8':
return 'utf8';
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return 'utf16le';
case 'latin1':
case 'binary':
return 'latin1';
case 'base64':
case 'ascii':
case 'hex':
return enc;
default:
if (retried) return; // undefined
enc = ('' + enc).toLowerCase();
retried = true;
}
}
};
function formatHash(urlObj, options) // Do not cache `Buffer.isEncoding` when checking encoding names as some
{ // modules monkey-patch it to support additional encodings
return urlObj.hash ? urlObj.hash : ""; function normalizeEncoding(enc) {
var nenc = _normalizeEncoding(enc);
if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncodi
ng(enc))) throw new Error('Unknown encoding: ' + enc);
return nenc || enc;
} }
function formatHost(urlObj, options) // StringDecoder provides an interface for efficiently splitting a series of
{ // buffers into a series of JS strings without breaking apart multi-byte
if (urlObj.host.full && (urlObj.extra.relation.maximumAuth || options.out // characters.
put===constants.ABSOLUTE)) exports.StringDecoder = StringDecoder;
{ function StringDecoder(encoding) {
return urlObj.host.full; this.encoding = normalizeEncoding(encoding);
} var nb;
switch (this.encoding) {
return ""; case 'utf16le':
this.text = utf16Text;
this.end = utf16End;
nb = 4;
break;
case 'utf8':
this.fillLast = utf8FillLast;
nb = 4;
break;
case 'base64':
this.text = base64Text;
this.end = base64End;
nb = 3;
break;
default:
this.write = simpleWrite;
this.end = simpleEnd;
return;
}
this.lastNeed = 0;
this.lastTotal = 0;
this.lastChar = Buffer.allocUnsafe(nb);
} }
function formatPath(urlObj, options) StringDecoder.prototype.write = function (buf) {
{ if (buf.length === 0) return '';
var str = ""; var r;
var i;
var absolutePath = urlObj.path.absolute.string; if (this.lastNeed) {
var relativePath = urlObj.path.relative.string; r = this.fillLast(buf);
var resource = showResource(urlObj, options); if (r === undefined) return '';
i = this.lastNeed;
if (urlObj.extra.relation.maximumHost || options.output===constants.ABSOL this.lastNeed = 0;
UTE || options.output===constants.ROOT_RELATIVE) } else {
{ i = 0;
str = absolutePath; }
} if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
else if (relativePath.length<=absolutePath.length && options.output===con return r || '';
stants.SHORTEST || options.output===constants.PATH_RELATIVE) };
{
str = relativePath;
if (str === "")
{
var query = showQuery(urlObj,options) && !!getQuery(urlOb
j,options);
if (urlObj.extra.relation.maximumPath && !resource)
{
str = "./";
}
else if (urlObj.extra.relation.overridesQuery && !resourc
e && !query)
{
str = "./";
}
}
}
else
{
str = absolutePath;
}
if ( str==="/" && !resource && options.removeRootTrailingSlash && (!urlOb
j.extra.relation.minimumPort || options.output===constants.ABSOLUTE) )
{
str = "";
}
return str; StringDecoder.prototype.end = utf8End;
}
function formatPort(urlObj, options) // Returns only complete characters in a Buffer
{ StringDecoder.prototype.text = utf8Text;
if (urlObj.port && !urlObj.extra.portIsDefault && urlObj.extra.relation.m
aximumHost)
{
return ":" + urlObj.port;
}
return ""; // Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
} StringDecoder.prototype.fillLast = function (buf) {
if (this.lastNeed <= buf.length) {
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
}
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
this.lastNeed -= buf.length;
};
function formatQuery(urlObj, options) // Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
{ // continuation byte. If an invalid byte is detected, -2 is returned.
return showQuery(urlObj,options) ? getQuery(urlObj, options) : ""; function utf8CheckByte(byte) {
if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte
>> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
return byte >> 6 === 0x02 ? -1 : -2;
} }
function formatResource(urlObj, options) // Checks at most 3 bytes at the end of a Buffer in order to detect an
{ // incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
return showResource(urlObj,options) ? urlObj.resource : ""; // needed to complete the UTF-8 character (if applicable) are returned.
function utf8CheckIncomplete(self, buf, i) {
var j = buf.length - 1;
if (j < i) return 0;
var nb = utf8CheckByte(buf[j]);
if (nb >= 0) {
if (nb > 0) self.lastNeed = nb - 1;
return nb;
}
if (--j < i || nb === -2) return 0;
nb = utf8CheckByte(buf[j]);
if (nb >= 0) {
if (nb > 0) self.lastNeed = nb - 2;
return nb;
}
if (--j < i || nb === -2) return 0;
nb = utf8CheckByte(buf[j]);
if (nb >= 0) {
if (nb > 0) {
if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
}
return nb;
}
return 0;
} }
function formatScheme(urlObj, options) // Validates as many continuation bytes for a multi-byte UTF-8 character as
{ // needed or are available. If we see a non-continuation byte where we expect
var str = ""; // one, we "replace" the validated continuation bytes we've seen so far with
// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
if (urlObj.extra.relation.maximumHost || options.output===constants.ABSOL // behavior. The continuation byte check is included three times in the case
UTE) // where all of the continuation bytes for a character exist in the same buffer.
{ // It is also done this way as a slight performance increase instead of using a
if (!urlObj.extra.relation.minimumScheme || !options.schemeRelati // loop.
ve || options.output===constants.ABSOLUTE) function utf8CheckExtraBytes(self, buf, p) {
if ((buf[0] & 0xC0) !== 0x80) {
self.lastNeed = 0;
return '\ufffd';
}
if (self.lastNeed > 1 && buf.length > 1) {
if ((buf[1] & 0xC0) !== 0x80) {
self.lastNeed = 1;
return '\ufffd';
}
if (self.lastNeed > 2 && buf.length > 2) {
if ((buf[2] & 0xC0) !== 0x80) {
self.lastNeed = 2;
return '\ufffd';
}
}
}
}
// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
function utf8FillLast(buf) {
var p = this.lastTotal - this.lastNeed;
var r = utf8CheckExtraBytes(this, buf, p);
if (r !== undefined) return r;
if (this.lastNeed <= buf.length) {
buf.copy(this.lastChar, p, 0, this.lastNeed);
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
}
buf.copy(this.lastChar, p, 0, buf.length);
this.lastNeed -= buf.length;
}
// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
// partial character, the character's bytes are buffered until the required
// number of bytes are available.
function utf8Text(buf, i) {
var total = utf8CheckIncomplete(this, buf, i);
if (!this.lastNeed) return buf.toString('utf8', i);
this.lastTotal = total;
var end = buf.length - (total - this.lastNeed);
buf.copy(this.lastChar, 0, end);
return buf.toString('utf8', i, end);
}
// For UTF-8, a replacement character is added when ending on a partial
// character.
function utf8End(buf) {
var r = buf && buf.length ? this.write(buf) : '';
if (this.lastNeed) return r + '\ufffd';
return r;
}
// UTF-16LE typically needs two bytes per character, but even if we have an even
// number of bytes available, we need to check if we end on a leading/high
// surrogate. In that case, we need to wait for the next two bytes in order to
// decode the last character properly.
function utf16Text(buf, i) {
if ((buf.length - i) % 2 === 0) {
var r = buf.toString('utf16le', i);
if (r) {
var c = r.charCodeAt(r.length - 1);
if (c >= 0xD800 && c <= 0xDBFF) {
this.lastNeed = 2;
this.lastTotal = 4;
this.lastChar[0] = buf[buf.length - 2];
this.lastChar[1] = buf[buf.length - 1];
return r.slice(0, -1);
}
}
return r;
}
this.lastNeed = 1;
this.lastTotal = 2;
this.lastChar[0] = buf[buf.length - 1];
return buf.toString('utf16le', i, buf.length - 1);
}
// For UTF-16LE we do not explicitly append special replacement characters if we
// end on a partial character, we simply let v8 handle that.
function utf16End(buf) {
var r = buf && buf.length ? this.write(buf) : '';
if (this.lastNeed) {
var end = this.lastTotal - this.lastNeed;
return r + this.lastChar.toString('utf16le', 0, end);
}
return r;
}
function base64Text(buf, i) {
var n = (buf.length - i) % 3;
if (n === 0) return buf.toString('base64', i);
this.lastNeed = 3 - n;
this.lastTotal = 3;
if (n === 1) {
this.lastChar[0] = buf[buf.length - 1];
} else {
this.lastChar[0] = buf[buf.length - 2];
this.lastChar[1] = buf[buf.length - 1];
}
return buf.toString('base64', i, buf.length - n);
}
function base64End(buf) {
var r = buf && buf.length ? this.write(buf) : '';
if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.las
tNeed);
return r;
}
// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
function simpleWrite(buf) {
return buf.toString(this.encoding);
}
function simpleEnd(buf) {
return buf && buf.length ? this.write(buf) : '';
}
},{"safe-buffer":144}],126:[function(require,module,exports){
exports = module.exports = require('./lib/_stream_readable.js');
exports.Stream = exports;
exports.Readable = exports;
exports.Writable = require('./lib/_stream_writable.js');
exports.Duplex = require('./lib/_stream_duplex.js');
exports.Transform = require('./lib/_stream_transform.js');
exports.PassThrough = require('./lib/_stream_passthrough.js');
},{"./lib/_stream_duplex.js":117,"./lib/_stream_passthrough.js":118,"./lib/_stre
am_readable.js":119,"./lib/_stream_transform.js":120,"./lib/_stream_writable.js"
:121}],127:[function(require,module,exports){
"use strict";
module.exports =
{
// Output
ABSOLUTE: "absolute",
PATH_RELATIVE: "pathRelative",
ROOT_RELATIVE: "rootRelative",
SHORTEST: "shortest"
};
},{}],128:[function(require,module,exports){
"use strict";
var constants = require("./constants");
function formatAuth(urlObj, options)
{
if (urlObj.auth && !options.removeAuth && (urlObj.extra.relation.maximumH
ost || options.output===constants.ABSOLUTE))
{
return urlObj.auth + "@";
}
return "";
}
function formatHash(urlObj, options)
{
return urlObj.hash ? urlObj.hash : "";
}
function formatHost(urlObj, options)
{
if (urlObj.host.full && (urlObj.extra.relation.maximumAuth || options.out
put===constants.ABSOLUTE))
{
return urlObj.host.full;
}
return "";
}
function formatPath(urlObj, options)
{
var str = "";
var absolutePath = urlObj.path.absolute.string;
var relativePath = urlObj.path.relative.string;
var resource = showResource(urlObj, options);
if (urlObj.extra.relation.maximumHost || options.output===constants.ABSOL
UTE || options.output===constants.ROOT_RELATIVE)
{
str = absolutePath;
}
else if (relativePath.length<=absolutePath.length && options.output===con
stants.SHORTEST || options.output===constants.PATH_RELATIVE)
{
str = relativePath;
if (str === "")
{
var query = showQuery(urlObj,options) && !!getQuery(urlOb
j,options);
if (urlObj.extra.relation.maximumPath && !resource)
{
str = "./";
}
else if (urlObj.extra.relation.overridesQuery && !resourc
e && !query)
{
str = "./";
}
}
}
else
{
str = absolutePath;
}
if ( str==="/" && !resource && options.removeRootTrailingSlash && (!urlOb
j.extra.relation.minimumPort || options.output===constants.ABSOLUTE) )
{
str = "";
}
return str;
}
function formatPort(urlObj, options)
{
if (urlObj.port && !urlObj.extra.portIsDefault && urlObj.extra.relation.m
aximumHost)
{
return ":" + urlObj.port;
}
return "";
}
function formatQuery(urlObj, options)
{
return showQuery(urlObj,options) ? getQuery(urlObj, options) : "";
}
function formatResource(urlObj, options)
{
return showResource(urlObj,options) ? urlObj.resource : "";
}
function formatScheme(urlObj, options)
{
var str = "";
if (urlObj.extra.relation.maximumHost || options.output===constants.ABSOL
UTE)
{
if (!urlObj.extra.relation.minimumScheme || !options.schemeRelati
ve || options.output===constants.ABSOLUTE)
{ {
str += urlObj.scheme + "://"; str += urlObj.scheme + "://";
} }
else else
{ {
str += "//"; str += "//";
} }
} }
return str; return str;
skipping to change at line 18005 skipping to change at line 18304
function showResource(urlObj, options) function showResource(urlObj, options)
{ {
var removeIndex = options.removeDirectoryIndexes && urlObj.extra.resource IsIndex; var removeIndex = options.removeDirectoryIndexes && urlObj.extra.resource IsIndex;
var removeMatchingResource = urlObj.extra.relation.minimumResource && opt ions.output!==constants.ABSOLUTE && options.output!==constants.ROOT_RELATIVE; var removeMatchingResource = urlObj.extra.relation.minimumResource && opt ions.output!==constants.ABSOLUTE && options.output!==constants.ROOT_RELATIVE;
return !!urlObj.resource && !removeMatchingResource && !removeIndex; return !!urlObj.resource && !removeMatchingResource && !removeIndex;
} }
module.exports = formatUrl; module.exports = formatUrl;
},{"./constants":126}],128:[function(require,module,exports){ },{"./constants":127}],129:[function(require,module,exports){
"use strict"; "use strict";
var constants = require("./constants"); var constants = require("./constants");
var formatUrl = require("./format"); var formatUrl = require("./format");
var getOptions = require("./options"); var getOptions = require("./options");
var objUtils = require("./util/object"); var objUtils = require("./util/object");
var parseUrl = require("./parse"); var parseUrl = require("./parse");
var relateUrl = require("./relate"); var relateUrl = require("./relate");
function RelateUrl(from, options) function RelateUrl(from, options)
skipping to change at line 18091 skipping to change at line 18390
RelateUrl.relate = function(from, to, options) RelateUrl.relate = function(from, to, options)
{ {
return new RelateUrl().relate(from, to, options); return new RelateUrl().relate(from, to, options);
} }
// Make constants accessible from API // Make constants accessible from API
objUtils.shallowMerge(RelateUrl, constants); objUtils.shallowMerge(RelateUrl, constants);
module.exports = RelateUrl; module.exports = RelateUrl;
},{"./constants":126,"./format":127,"./options":129,"./parse":132,"./relate":139 ,"./util/object":141}],129:[function(require,module,exports){ },{"./constants":127,"./format":128,"./options":130,"./parse":133,"./relate":140 ,"./util/object":142}],130:[function(require,module,exports){
"use strict"; "use strict";
var objUtils = require("./util/object"); var objUtils = require("./util/object");
function getOptions(options, defaults) function getOptions(options, defaults)
{ {
if ( objUtils.isPlainObject(options) ) if ( objUtils.isPlainObject(options) )
{ {
var newOptions = {}; var newOptions = {};
skipping to change at line 18144 skipping to change at line 18443
{ {
return objUtils.shallowMerge(newValues, defaultValues); return objUtils.shallowMerge(newValues, defaultValues);
} }
} }
return newValues; return newValues;
} }
module.exports = getOptions; module.exports = getOptions;
},{"./util/object":141}],130:[function(require,module,exports){ },{"./util/object":142}],131:[function(require,module,exports){
"use strict"; "use strict";
function parseHost(urlObj, options) function parseHost(urlObj, options)
{ {
// TWEAK :: condition only for speed optimization // TWEAK :: condition only for speed optimization
if (options.ignore_www) if (options.ignore_www)
{ {
var host = urlObj.host.full; var host = urlObj.host.full;
if (host) if (host)
skipping to change at line 18170 skipping to change at line 18469
stripped = host.substr(4); stripped = host.substr(4);
} }
urlObj.host.stripped = stripped; urlObj.host.stripped = stripped;
} }
} }
} }
module.exports = parseHost; module.exports = parseHost;
},{}],131:[function(require,module,exports){ },{}],132:[function(require,module,exports){
"use strict"; "use strict";
function hrefInfo(urlObj) function hrefInfo(urlObj)
{ {
var minimumPathOnly = (!urlObj.scheme && !urlObj.auth && !urlObj.host .full && !urlObj.port); var minimumPathOnly = (!urlObj.scheme && !urlObj.auth && !urlObj.host .full && !urlObj.port);
var minimumResourceOnly = (minimumPathOnly && !urlObj.path.absolute.strin g); var minimumResourceOnly = (minimumPathOnly && !urlObj.path.absolute.strin g);
var minimumQueryOnly = (minimumResourceOnly && !urlObj.resource); var minimumQueryOnly = (minimumResourceOnly && !urlObj.resource);
var minimumHashOnly = (minimumQueryOnly && !urlObj.query.string.full. length); var minimumHashOnly = (minimumQueryOnly && !urlObj.query.string.full. length);
var empty = (minimumHashOnly && !urlObj.hash); var empty = (minimumHashOnly && !urlObj.hash);
urlObj.extra.hrefInfo.minimumPathOnly = minimumPathOnly; urlObj.extra.hrefInfo.minimumPathOnly = minimumPathOnly;
urlObj.extra.hrefInfo.minimumResourceOnly = minimumResourceOnly; urlObj.extra.hrefInfo.minimumResourceOnly = minimumResourceOnly;
urlObj.extra.hrefInfo.minimumQueryOnly = minimumQueryOnly; urlObj.extra.hrefInfo.minimumQueryOnly = minimumQueryOnly;
urlObj.extra.hrefInfo.minimumHashOnly = minimumHashOnly; urlObj.extra.hrefInfo.minimumHashOnly = minimumHashOnly;
urlObj.extra.hrefInfo.empty = empty; urlObj.extra.hrefInfo.empty = empty;
} }
module.exports = hrefInfo; module.exports = hrefInfo;
},{}],132:[function(require,module,exports){ },{}],133:[function(require,module,exports){
"use strict"; "use strict";
var hrefInfo = require("./hrefInfo"); var hrefInfo = require("./hrefInfo");
var parseHost = require("./host"); var parseHost = require("./host");
var parsePath = require("./path"); var parsePath = require("./path");
var parsePort = require("./port"); var parsePort = require("./port");
var parseQuery = require("./query"); var parseQuery = require("./query");
var parseUrlString = require("./urlstring"); var parseUrlString = require("./urlstring");
var pathUtils = require("../util/path"); var pathUtils = require("../util/path");
skipping to change at line 18244 skipping to change at line 18543
return urlObj; return urlObj;
} }
module.exports = module.exports =
{ {
from: parseFromUrl, from: parseFromUrl,
to: parseUrl to: parseUrl
}; };
},{"../util/path":142,"./host":130,"./hrefInfo":131,"./path":133,"./port":134,". /query":135,"./urlstring":136}],133:[function(require,module,exports){ },{"../util/path":143,"./host":131,"./hrefInfo":132,"./path":134,"./port":135,". /query":136,"./urlstring":137}],134:[function(require,module,exports){
"use strict"; "use strict";
function isDirectoryIndex(resource, options) function isDirectoryIndex(resource, options)
{ {
var verdict = false; var verdict = false;
options.directoryIndexes.every( function(index) options.directoryIndexes.every( function(index)
{ {
if (index === resource) if (index === resource)
{ {
skipping to change at line 18340 skipping to change at line 18639
} }
else else
{ {
// Faster to skip the above block and just create an array // Faster to skip the above block and just create an array
return []; return [];
} }
} }
module.exports = parsePath; module.exports = parsePath;
},{}],134:[function(require,module,exports){ },{}],135:[function(require,module,exports){
"use strict"; "use strict";
function parsePort(urlObj, options) function parsePort(urlObj, options)
{ {
var defaultPort = -1; var defaultPort = -1;
for (var i in options.defaultPorts) for (var i in options.defaultPorts)
{ {
if ( i===urlObj.scheme && options.defaultPorts.hasOwnProperty(i) ) if ( i===urlObj.scheme && options.defaultPorts.hasOwnProperty(i) )
{ {
skipping to change at line 18372 skipping to change at line 18671
{ {
urlObj.port = defaultPort; urlObj.port = defaultPort;
} }
urlObj.extra.portIsDefault = (urlObj.port === defaultPort); urlObj.extra.portIsDefault = (urlObj.port === defaultPort);
} }
} }
module.exports = parsePort; module.exports = parsePort;
},{}],135:[function(require,module,exports){ },{}],136:[function(require,module,exports){
"use strict"; "use strict";
var hasOwnProperty = Object.prototype.hasOwnProperty; var hasOwnProperty = Object.prototype.hasOwnProperty;
function parseQuery(urlObj, options) function parseQuery(urlObj, options)
{ {
urlObj.query.string.full = stringify(urlObj.query.object, false); urlObj.query.string.full = stringify(urlObj.query.object, false);
// TWEAK :: condition only for speed optimization // TWEAK :: condition only for speed optimization
if (options.removeEmptyQueries) if (options.removeEmptyQueries)
{ {
skipping to change at line 18421 skipping to change at line 18720
} }
} }
} }
} }
return str; return str;
} }
module.exports = parseQuery; module.exports = parseQuery;
},{}],136:[function(require,module,exports){ },{}],137:[function(require,module,exports){
"use strict"; "use strict";
var _parseUrl = require("url").parse; var _parseUrl = require("url").parse;
/* /*
Customize the URL object that Node generates Customize the URL object that Node generates
because: because:
* necessary data for later * necessary data for later
* urlObj.host is useless * urlObj.host is useless
skipping to change at line 18561 skipping to change at line 18860
return clean( _parseUrl(url, true, options.slashesDenoteHost) ); return clean( _parseUrl(url, true, options.slashesDenoteHost) );
} }
else else
{ {
return {href:url, valid:false}; return {href:url, valid:false};
} }
} }
module.exports = parseUrlString; module.exports = parseUrlString;
},{"url":162}],137:[function(require,module,exports){ },{"url":162}],138:[function(require,module,exports){
"use strict"; "use strict";
var findRelation = require("./findRelation"); var findRelation = require("./findRelation");
var objUtils = require("../util/object"); var objUtils = require("../util/object");
var pathUtils = require("../util/path"); var pathUtils = require("../util/path");
function absolutize(urlObj, siteUrlObj, options) function absolutize(urlObj, siteUrlObj, options)
{ {
findRelation.upToPath(urlObj, siteUrlObj, options); findRelation.upToPath(urlObj, siteUrlObj, options);
skipping to change at line 18642 skipping to change at line 18941
function copyResource(urlObj, siteUrlObj) function copyResource(urlObj, siteUrlObj)
{ {
urlObj.resource = siteUrlObj.resource; urlObj.resource = siteUrlObj.resource;
urlObj.extra.resourceIsIndex = siteUrlObj.extra.resourceIsIndex; urlObj.extra.resourceIsIndex = siteUrlObj.extra.resourceIsIndex;
} }
module.exports = absolutize; module.exports = absolutize;
},{"../util/object":141,"../util/path":142,"./findRelation":138}],138:[function( require,module,exports){ },{"../util/object":142,"../util/path":143,"./findRelation":139}],139:[function( require,module,exports){
"use strict"; "use strict";
function findRelation_upToPath(urlObj, siteUrlObj, options) function findRelation_upToPath(urlObj, siteUrlObj, options)
{ {
// Path- or root-relative URL // Path- or root-relative URL
var pathOnly = urlObj.extra.hrefInfo.minimumPathOnly; var pathOnly = urlObj.extra.hrefInfo.minimumPathOnly;
// Matching scheme, scheme-relative or path-only // Matching scheme, scheme-relative or path-only
var minimumScheme = (urlObj.scheme===siteUrlObj.scheme || !urlObj.scheme) ; var minimumScheme = (urlObj.scheme===siteUrlObj.scheme || !urlObj.scheme) ;
skipping to change at line 18719 skipping to change at line 19018
// Matching path and/or resource with existing but non-matching site quer y // Matching path and/or resource with existing but non-matching site quer y
urlObj.extra.relation.overridesQuery = minimumPath && urlObj.extra.relat ion.maximumResource && !minimumQuery && !!siteUrlQuery; urlObj.extra.relation.overridesQuery = minimumPath && urlObj.extra.relat ion.maximumResource && !minimumQuery && !!siteUrlQuery;
} }
module.exports = module.exports =
{ {
pathOn: findRelation_pathOn, pathOn: findRelation_pathOn,
upToPath: findRelation_upToPath upToPath: findRelation_upToPath
}; };
},{}],139:[function(require,module,exports){ },{}],140:[function(require,module,exports){
"use strict"; "use strict";
var absolutize = require("./absolutize"); var absolutize = require("./absolutize");
var relativize = require("./relativize"); var relativize = require("./relativize");
function relateUrl(siteUrlObj, urlObj, options) function relateUrl(siteUrlObj, urlObj, options)
{ {
absolutize(urlObj, siteUrlObj, options); absolutize(urlObj, siteUrlObj, options);
relativize(urlObj, siteUrlObj, options); relativize(urlObj, siteUrlObj, options);
return urlObj; return urlObj;
} }
module.exports = relateUrl; module.exports = relateUrl;
},{"./absolutize":137,"./relativize":140}],140:[function(require,module,exports) { },{"./absolutize":138,"./relativize":141}],141:[function(require,module,exports) {
"use strict"; "use strict";
var pathUtils = require("../util/path"); var pathUtils = require("../util/path");
/* /*
Get a path relative to the site path. Get a path relative to the site path.
*/ */
function relatePath(absolutePath, siteAbsolutePath) function relatePath(absolutePath, siteAbsolutePath)
{ {
var relativePath = []; var relativePath = [];
skipping to change at line 18798 skipping to change at line 19097
{ {
var pathArray = relatePath(urlObj.path.absolute.array, siteUrlObj .path.absolute.array); var pathArray = relatePath(urlObj.path.absolute.array, siteUrlObj .path.absolute.array);
urlObj.path.relative.array = pathArray; urlObj.path.relative.array = pathArray;
urlObj.path.relative.string = pathUtils.join(pathArray); urlObj.path.relative.string = pathUtils.join(pathArray);
} }
} }
module.exports = relativize; module.exports = relativize;
},{"../util/path":142}],141:[function(require,module,exports){ },{"../util/path":143}],142:[function(require,module,exports){
"use strict"; "use strict";
/* /*
Deep-clone an object. Deep-clone an object.
*/ */
function clone(obj) function clone(obj)
{ {
if (obj instanceof Object) if (obj instanceof Object)
{ {
var clonedObj = (obj instanceof Array) ? [] : {}; var clonedObj = (obj instanceof Array) ? [] : {};
skipping to change at line 18858 skipping to change at line 19157
return target; return target;
} }
module.exports = module.exports =
{ {
clone: clone, clone: clone,
isPlainObject: isPlainObject, isPlainObject: isPlainObject,
shallowMerge: shallowMerge shallowMerge: shallowMerge
}; };
},{}],142:[function(require,module,exports){ },{}],143:[function(require,module,exports){
"use strict"; "use strict";
function joinPath(pathArray) function joinPath(pathArray)
{ {
if (pathArray.length > 0) if (pathArray.length > 0)
{ {
return pathArray.join("/") + "/"; return pathArray.join("/") + "/";
} }
else else
{ {
skipping to change at line 18905 skipping to change at line 19204
return pathAbsolute; return pathAbsolute;
} }
module.exports = module.exports =
{ {
join: joinPath, join: joinPath,
resolveDotSegments: resolveDotSegments resolveDotSegments: resolveDotSegments
}; };
},{}],143:[function(require,module,exports){ },{}],144:[function(require,module,exports){
/* eslint-disable node/no-deprecated-api */ /* eslint-disable node/no-deprecated-api */
var buffer = require('buffer') var buffer = require('buffer')
var Buffer = buffer.Buffer var Buffer = buffer.Buffer
// alternative to using Object.keys for old browsers // alternative to using Object.keys for old browsers
function copyProps (src, dst) { function copyProps (src, dst) {
for (var key in src) { for (var key in src) {
dst[key] = src[key] dst[key] = src[key]
} }
} }
skipping to change at line 18969 skipping to change at line 19268
return Buffer(size) return Buffer(size)
} }
SafeBuffer.allocUnsafeSlow = function (size) { SafeBuffer.allocUnsafeSlow = function (size) {
if (typeof size !== 'number') { if (typeof size !== 'number') {
throw new TypeError('Argument must be a number') throw new TypeError('Argument must be a number')
} }
return buffer.SlowBuffer(size) return buffer.SlowBuffer(size)
} }
},{"buffer":4}],144:[function(require,module,exports){ },{"buffer":4}],145:[function(require,module,exports){
/* -*- Mode: js; js-indent-level: 2; -*- */ /* -*- Mode: js; js-indent-level: 2; -*- */
/* /*
* Copyright 2011 Mozilla Foundation and contributors * Copyright 2011 Mozilla Foundation and contributors
* Licensed under the New BSD license. See LICENSE or: * Licensed under the New BSD license. See LICENSE or:
* http://opensource.org/licenses/BSD-3-Clause * http://opensource.org/licenses/BSD-3-Clause
*/ */
var util = require('./util'); var util = require('./util');
var has = Object.prototype.hasOwnProperty; var has = Object.prototype.hasOwnProperty;
var hasNativeMap = typeof Map !== "undefined"; var hasNativeMap = typeof Map !== "undefined";
skipping to change at line 19092 skipping to change at line 19391
* Returns the array representation of this set (which has the proper indices * Returns the array representation of this set (which has the proper indices
* indicated by indexOf). Note that this is a copy of the internal array used * indicated by indexOf). Note that this is a copy of the internal array used
* for storing the members so that no one can mess with internal state. * for storing the members so that no one can mess with internal state.
*/ */
ArraySet.prototype.toArray = function ArraySet_toArray() { ArraySet.prototype.toArray = function ArraySet_toArray() {
return this._array.slice(); return this._array.slice();
}; };
exports.ArraySet = ArraySet; exports.ArraySet = ArraySet;
},{"./util":153}],145:[function(require,module,exports){ },{"./util":154}],146:[function(require,module,exports){
/* -*- Mode: js; js-indent-level: 2; -*- */ /* -*- Mode: js; js-indent-level: 2; -*- */
/* /*
* Copyright 2011 Mozilla Foundation and contributors * Copyright 2011 Mozilla Foundation and contributors
* Licensed under the New BSD license. See LICENSE or: * Licensed under the New BSD license. See LICENSE or:
* http://opensource.org/licenses/BSD-3-Clause * http://opensource.org/licenses/BSD-3-Clause
* *
* Based on the Base 64 VLQ implementation in Closure Compiler: * Based on the Base 64 VLQ implementation in Closure Compiler:
* https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google /debugging/sourcemap/Base64VLQ.java * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google /debugging/sourcemap/Base64VLQ.java
* *
* Copyright 2011 The Closure Compiler Authors. All rights reserved. * Copyright 2011 The Closure Compiler Authors. All rights reserved.
skipping to change at line 19234 skipping to change at line 19533
continuation = !!(digit & VLQ_CONTINUATION_BIT); continuation = !!(digit & VLQ_CONTINUATION_BIT);
digit &= VLQ_BASE_MASK; digit &= VLQ_BASE_MASK;
result = result + (digit << shift); result = result + (digit << shift);
shift += VLQ_BASE_SHIFT; shift += VLQ_BASE_SHIFT;
} while (continuation); } while (continuation);
aOutParam.value = fromVLQSigned(result); aOutParam.value = fromVLQSigned(result);
aOutParam.rest = aIndex; aOutParam.rest = aIndex;
}; };
},{"./base64":146}],146:[function(require,module,exports){ },{"./base64":147}],147:[function(require,module,exports){
/* -*- Mode: js; js-indent-level: 2; -*- */ /* -*- Mode: js; js-indent-level: 2; -*- */
/* /*
* Copyright 2011 Mozilla Foundation and contributors * Copyright 2011 Mozilla Foundation and contributors
* Licensed under the New BSD license. See LICENSE or: * Licensed under the New BSD license. See LICENSE or:
* http://opensource.org/licenses/BSD-3-Clause * http://opensource.org/licenses/BSD-3-Clause
*/ */
var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567 89+/'.split(''); var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567 89+/'.split('');
/** /**
skipping to change at line 19303 skipping to change at line 19602
// 63: / // 63: /
if (charCode == slash) { if (charCode == slash) {
return 63; return 63;
} }
// Invalid base64 digit. // Invalid base64 digit.
return -1; return -1;
}; };
},{}],147:[function(require,module,exports){ },{}],148:[function(require,module,exports){
/* -*- Mode: js; js-indent-level: 2; -*- */ /* -*- Mode: js; js-indent-level: 2; -*- */
/* /*
* Copyright 2011 Mozilla Foundation and contributors * Copyright 2011 Mozilla Foundation and contributors
* Licensed under the New BSD license. See LICENSE or: * Licensed under the New BSD license. See LICENSE or:
* http://opensource.org/licenses/BSD-3-Clause * http://opensource.org/licenses/BSD-3-Clause
*/ */
exports.GREATEST_LOWER_BOUND = 1; exports.GREATEST_LOWER_BOUND = 1;
exports.LEAST_UPPER_BOUND = 2; exports.LEAST_UPPER_BOUND = 2;
skipping to change at line 19416 skipping to change at line 19715
while (index - 1 >= 0) { while (index - 1 >= 0) {
if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) { if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
break; break;
} }
--index; --index;
} }
return index; return index;
}; };
},{}],148:[function(require,module,exports){ },{}],149:[function(require,module,exports){
/* -*- Mode: js; js-indent-level: 2; -*- */ /* -*- Mode: js; js-indent-level: 2; -*- */
/* /*
* Copyright 2014 Mozilla Foundation and contributors * Copyright 2014 Mozilla Foundation and contributors
* Licensed under the New BSD license. See LICENSE or: * Licensed under the New BSD license. See LICENSE or:
* http://opensource.org/licenses/BSD-3-Clause * http://opensource.org/licenses/BSD-3-Clause
*/ */
var util = require('./util'); var util = require('./util');
/** /**
skipping to change at line 19497 skipping to change at line 19796
MappingList.prototype.toArray = function MappingList_toArray() { MappingList.prototype.toArray = function MappingList_toArray() {
if (!this._sorted) { if (!this._sorted) {
this._array.sort(util.compareByGeneratedPositionsInflated); this._array.sort(util.compareByGeneratedPositionsInflated);
this._sorted = true; this._sorted = true;
} }
return this._array; return this._array;
}; };
exports.MappingList = MappingList; exports.MappingList = MappingList;
},{"./util":153}],149:[function(require,module,exports){ },{"./util":154}],150:[function(require,module,exports){
/* -*- Mode: js; js-indent-level: 2; -*- */ /* -*- Mode: js; js-indent-level: 2; -*- */
/* /*
* Copyright 2011 Mozilla Foundation and contributors * Copyright 2011 Mozilla Foundation and contributors
* Licensed under the New BSD license. See LICENSE or: * Licensed under the New BSD license. See LICENSE or:
* http://opensource.org/licenses/BSD-3-Clause * http://opensource.org/licenses/BSD-3-Clause
*/ */
// It turns out that some (most?) JavaScript engines don't self-host // It turns out that some (most?) JavaScript engines don't self-host
// `Array.prototype.sort`. This makes sense because C++ will likely remain // `Array.prototype.sort`. This makes sense because C++ will likely remain
// faster than JS when doing raw CPU-intensive sorting. However, when using a // faster than JS when doing raw CPU-intensive sorting. However, when using a
skipping to change at line 19613 skipping to change at line 19912
* *
* @param {Array} ary * @param {Array} ary
* An array to sort. * An array to sort.
* @param {function} comparator * @param {function} comparator
* Function to use to compare two items. * Function to use to compare two items.
*/ */
exports.quickSort = function (ary, comparator) { exports.quickSort = function (ary, comparator) {
doQuickSort(ary, comparator, 0, ary.length - 1); doQuickSort(ary, comparator, 0, ary.length - 1);
}; };
},{}],150:[function(require,module,exports){ },{}],151:[function(require,module,exports){
/* -*- Mode: js; js-indent-level: 2; -*- */ /* -*- Mode: js; js-indent-level: 2; -*- */
/* /*
* Copyright 2011 Mozilla Foundation and contributors * Copyright 2011 Mozilla Foundation and contributors
* Licensed under the New BSD license. See LICENSE or: * Licensed under the New BSD license. See LICENSE or:
* http://opensource.org/licenses/BSD-3-Clause * http://opensource.org/licenses/BSD-3-Clause
*/ */
var util = require('./util'); var util = require('./util');
var binarySearch = require('./binary-search'); var binarySearch = require('./binary-search');
var ArraySet = require('./array-set').ArraySet; var ArraySet = require('./array-set').ArraySet;
skipping to change at line 20760 skipping to change at line 21059
} }
} }
} }
quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated ); quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated );
quickSort(this.__originalMappings, util.compareByOriginalPositions); quickSort(this.__originalMappings, util.compareByOriginalPositions);
}; };
exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer; exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
},{"./array-set":144,"./base64-vlq":145,"./binary-search":147,"./quick-sort":149 ,"./util":153}],151:[function(require,module,exports){ },{"./array-set":145,"./base64-vlq":146,"./binary-search":148,"./quick-sort":150 ,"./util":154}],152:[function(require,module,exports){
/* -*- Mode: js; js-indent-level: 2; -*- */ /* -*- Mode: js; js-indent-level: 2; -*- */
/* /*
* Copyright 2011 Mozilla Foundation and contributors * Copyright 2011 Mozilla Foundation and contributors
* Licensed under the New BSD license. See LICENSE or: * Licensed under the New BSD license. See LICENSE or:
* http://opensource.org/licenses/BSD-3-Clause * http://opensource.org/licenses/BSD-3-Clause
*/ */
var base64VLQ = require('./base64-vlq'); var base64VLQ = require('./base64-vlq');
var util = require('./util'); var util = require('./util');
var ArraySet = require('./array-set').ArraySet; var ArraySet = require('./array-set').ArraySet;
skipping to change at line 21187 skipping to change at line 21486
/** /**
* Render the source map being generated to a string. * Render the source map being generated to a string.
*/ */
SourceMapGenerator.prototype.toString = SourceMapGenerator.prototype.toString =
function SourceMapGenerator_toString() { function SourceMapGenerator_toString() {
return JSON.stringify(this.toJSON()); return JSON.stringify(this.toJSON());
}; };
exports.SourceMapGenerator = SourceMapGenerator; exports.SourceMapGenerator = SourceMapGenerator;
},{"./array-set":144,"./base64-vlq":145,"./mapping-list":148,"./util":153}],152: [function(require,module,exports){ },{"./array-set":145,"./base64-vlq":146,"./mapping-list":149,"./util":154}],153: [function(require,module,exports){
/* -*- Mode: js; js-indent-level: 2; -*- */ /* -*- Mode: js; js-indent-level: 2; -*- */
/* /*
* Copyright 2011 Mozilla Foundation and contributors * Copyright 2011 Mozilla Foundation and contributors
* Licensed under the New BSD license. See LICENSE or: * Licensed under the New BSD license. See LICENSE or:
* http://opensource.org/licenses/BSD-3-Clause * http://opensource.org/licenses/BSD-3-Clause
*/ */
var SourceMapGenerator = require('./source-map-generator').SourceMapGenerator; var SourceMapGenerator = require('./source-map-generator').SourceMapGenerator;
var util = require('./util'); var util = require('./util');
skipping to change at line 21602 skipping to change at line 21901
}); });
this.walkSourceContents(function (sourceFile, sourceContent) { this.walkSourceContents(function (sourceFile, sourceContent) {
map.setSourceContent(sourceFile, sourceContent); map.setSourceContent(sourceFile, sourceContent);
}); });
return { code: generated.code, map: map }; return { code: generated.code, map: map };
}; };
exports.SourceNode = SourceNode; exports.SourceNode = SourceNode;
},{"./source-map-generator":151,"./util":153}],153:[function(require,module,expo rts){ },{"./source-map-generator":152,"./util":154}],154:[function(require,module,expo rts){
/* -*- Mode: js; js-indent-level: 2; -*- */ /* -*- Mode: js; js-indent-level: 2; -*- */
/* /*
* Copyright 2011 Mozilla Foundation and contributors * Copyright 2011 Mozilla Foundation and contributors
* Licensed under the New BSD license. See LICENSE or: * Licensed under the New BSD license. See LICENSE or:
* http://opensource.org/licenses/BSD-3-Clause * http://opensource.org/licenses/BSD-3-Clause
*/ */
/** /**
* This is a helper function for getting values from parameter/options * This is a helper function for getting values from parameter/options
* objects. * objects.
skipping to change at line 22092 skipping to change at line 22391
parsed.path = parsed.path.substring(0, index + 1); parsed.path = parsed.path.substring(0, index + 1);
} }
} }
sourceURL = join(urlGenerate(parsed), sourceURL); sourceURL = join(urlGenerate(parsed), sourceURL);
} }
return normalize(sourceURL); return normalize(sourceURL);
} }
exports.computeSourceURL = computeSourceURL; exports.computeSourceURL = computeSourceURL;
},{}],154:[function(require,module,exports){ },{}],155:[function(require,module,exports){
/* /*
* Copyright 2009-2011 Mozilla Foundation and contributors * Copyright 2009-2011 Mozilla Foundation and contributors
* Licensed under the New BSD license. See LICENSE.txt or: * Licensed under the New BSD license. See LICENSE.txt or:
* http://opensource.org/licenses/BSD-3-Clause * http://opensource.org/licenses/BSD-3-Clause
*/ */
exports.SourceMapGenerator = require('./lib/source-map-generator').SourceMapGene rator; exports.SourceMapGenerator = require('./lib/source-map-generator').SourceMapGene rator;
exports.SourceMapConsumer = require('./lib/source-map-consumer').SourceMapConsum er; exports.SourceMapConsumer = require('./lib/source-map-consumer').SourceMapConsum er;
exports.SourceNode = require('./lib/source-node').SourceNode; exports.SourceNode = require('./lib/source-node').SourceNode;
},{"./lib/source-map-consumer":150,"./lib/source-map-generator":151,"./lib/sourc e-node":152}],155:[function(require,module,exports){ },{"./lib/source-map-consumer":151,"./lib/source-map-generator":152,"./lib/sourc e-node":153}],156:[function(require,module,exports){
(function (global){ (function (global){
var ClientRequest = require('./lib/request') var ClientRequest = require('./lib/request')
var response = require('./lib/response') var response = require('./lib/response')
var extend = require('xtend') var extend = require('xtend')
var statusCodes = require('builtin-status-codes') var statusCodes = require('builtin-status-codes')
var url = require('url') var url = require('url')
var http = exports var http = exports
http.request = function (opts, cb) { http.request = function (opts, cb) {
skipping to change at line 22190 skipping to change at line 22489
'PURGE', 'PURGE',
'PUT', 'PUT',
'REPORT', 'REPORT',
'SEARCH', 'SEARCH',
'SUBSCRIBE', 'SUBSCRIBE',
'TRACE', 'TRACE',
'UNLOCK', 'UNLOCK',
'UNSUBSCRIBE' 'UNSUBSCRIBE'
] ]
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined " ? self : typeof window !== "undefined" ? window : {}) }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined " ? self : typeof window !== "undefined" ? window : {})
},{"./lib/request":157,"./lib/response":158,"builtin-status-codes":5,"url":162," xtend":165}],156:[function(require,module,exports){ },{"./lib/request":158,"./lib/response":159,"builtin-status-codes":5,"url":162," xtend":165}],157:[function(require,module,exports){
(function (global){ (function (global){
exports.fetch = isFunction(global.fetch) && isFunction(global.ReadableStream) exports.fetch = isFunction(global.fetch) && isFunction(global.ReadableStream)
exports.writableStream = isFunction(global.WritableStream) exports.writableStream = isFunction(global.WritableStream)
exports.abortController = isFunction(global.AbortController) exports.abortController = isFunction(global.AbortController)
exports.blobConstructor = false exports.blobConstructor = false
try { try {
new Blob([new ArrayBuffer(1)]) new Blob([new ArrayBuffer(1)])
skipping to change at line 22267 skipping to change at line 22566
exports.vbArray = isFunction(global.VBArray) exports.vbArray = isFunction(global.VBArray)
function isFunction (value) { function isFunction (value) {
return typeof value === 'function' return typeof value === 'function'
} }
xhr = null // Help gc xhr = null // Help gc
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined " ? self : typeof window !== "undefined" ? window : {}) }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined " ? self : typeof window !== "undefined" ? window : {})
},{}],157:[function(require,module,exports){ },{}],158:[function(require,module,exports){
(function (process,global,Buffer){ (function (process,global,Buffer){
var capability = require('./capability') var capability = require('./capability')
var inherits = require('inherits') var inherits = require('inherits')
var response = require('./response') var response = require('./response')
var stream = require('readable-stream') var stream = require('readable-stream')
var toArrayBuffer = require('to-arraybuffer') var toArrayBuffer = require('to-arraybuffer')
var IncomingMessage = response.IncomingMessage var IncomingMessage = response.IncomingMessage
var rStates = response.readyStates var rStates = response.readyStates
skipping to change at line 22598 skipping to change at line 22897
'origin', 'origin',
'referer', 'referer',
'te', 'te',
'trailer', 'trailer',
'transfer-encoding', 'transfer-encoding',
'upgrade', 'upgrade',
'via' 'via'
] ]
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},requi re("buffer").Buffer) }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},requi re("buffer").Buffer)
},{"./capability":156,"./response":158,"_process":112,"buffer":4,"inherits":106, "readable-stream":125,"to-arraybuffer":161}],158:[function(require,module,export s){ },{"./capability":157,"./response":159,"_process":112,"buffer":4,"inherits":106, "readable-stream":126,"to-arraybuffer":161}],159:[function(require,module,export s){
(function (process,global,Buffer){ (function (process,global,Buffer){
var capability = require('./capability') var capability = require('./capability')
var inherits = require('inherits') var inherits = require('inherits')
var stream = require('readable-stream') var stream = require('readable-stream')
var rStates = exports.readyStates = { var rStates = exports.readyStates = {
UNSENT: 0, UNSENT: 0,
OPENED: 1, OPENED: 1,
HEADERS_RECEIVED: 2, HEADERS_RECEIVED: 2,
LOADING: 3, LOADING: 3,
skipping to change at line 22826 skipping to change at line 23125
break break
} }
// The ms-stream case handles end separately in reader.onload() // The ms-stream case handles end separately in reader.onload()
if (self._xhr.readyState === rStates.DONE && self._mode !== 'ms-stream') { if (self._xhr.readyState === rStates.DONE && self._mode !== 'ms-stream') {
self.push(null) self.push(null)
} }
} }
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},requi re("buffer").Buffer) }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},requi re("buffer").Buffer)
},{"./capability":156,"_process":112,"buffer":4,"inherits":106,"readable-stream" },{"./capability":157,"_process":112,"buffer":4,"inherits":106,"readable-stream"
:125}],159:[function(require,module,exports){ :126}],160:[function(require,module,exports){
// Copyright Joyent, Inc. and other Node 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.
'use strict';
/*<replacement>*/
var Buffer = require('safe-buffer').Buffer;
/*</replacement>*/
var isEncoding = Buffer.isEncoding || function (encoding) {
encoding = '' + encoding;
switch (encoding && encoding.toLowerCase()) {
case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64'
:case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
return true;
default:
return false;
}
};
function _normalizeEncoding(enc) {
if (!enc) return 'utf8';
var retried;
while (true) {
switch (enc) {
case 'utf8':
case 'utf-8':
return 'utf8';
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return 'utf16le';
case 'latin1':
case 'binary':
return 'latin1';
case 'base64':
case 'ascii':
case 'hex':
return enc;
default:
if (retried) return; // undefined
enc = ('' + enc).toLowerCase();
retried = true;
}
}
};
// Do not cache `Buffer.isEncoding` when checking encoding names as some
// modules monkey-patch it to support additional encodings
function normalizeEncoding(enc) {
var nenc = _normalizeEncoding(enc);
if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncodi
ng(enc))) throw new Error('Unknown encoding: ' + enc);
return nenc || enc;
}
// StringDecoder provides an interface for efficiently splitting a series of
// buffers into a series of JS strings without breaking apart multi-byte
// characters.
exports.StringDecoder = StringDecoder;
function StringDecoder(encoding) {
this.encoding = normalizeEncoding(encoding);
var nb;
switch (this.encoding) {
case 'utf16le':
this.text = utf16Text;
this.end = utf16End;
nb = 4;
break;
case 'utf8':
this.fillLast = utf8FillLast;
nb = 4;
break;
case 'base64':
this.text = base64Text;
this.end = base64End;
nb = 3;
break;
default:
this.write = simpleWrite;
this.end = simpleEnd;
return;
}
this.lastNeed = 0;
this.lastTotal = 0;
this.lastChar = Buffer.allocUnsafe(nb);
}
StringDecoder.prototype.write = function (buf) {
if (buf.length === 0) return '';
var r;
var i;
if (this.lastNeed) {
r = this.fillLast(buf);
if (r === undefined) return '';
i = this.lastNeed;
this.lastNeed = 0;
} else {
i = 0;
}
if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
return r || '';
};
StringDecoder.prototype.end = utf8End;
// Returns only complete characters in a Buffer
StringDecoder.prototype.text = utf8Text;
// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
StringDecoder.prototype.fillLast = function (buf) {
if (this.lastNeed <= buf.length) {
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
}
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
this.lastNeed -= buf.length;
};
// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
// continuation byte. If an invalid byte is detected, -2 is returned.
function utf8CheckByte(byte) {
if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte
>> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
return byte >> 6 === 0x02 ? -1 : -2;
}
// Checks at most 3 bytes at the end of a Buffer in order to detect an
// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
// needed to complete the UTF-8 character (if applicable) are returned.
function utf8CheckIncomplete(self, buf, i) {
var j = buf.length - 1;
if (j < i) return 0;
var nb = utf8CheckByte(buf[j]);
if (nb >= 0) {
if (nb > 0) self.lastNeed = nb - 1;
return nb;
}
if (--j < i || nb === -2) return 0;
nb = utf8CheckByte(buf[j]);
if (nb >= 0) {
if (nb > 0) self.lastNeed = nb - 2;
return nb;
}
if (--j < i || nb === -2) return 0;
nb = utf8CheckByte(buf[j]);
if (nb >= 0) {
if (nb > 0) {
if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
}
return nb;
}
return 0;
}
// Validates as many continuation bytes for a multi-byte UTF-8 character as
// needed or are available. If we see a non-continuation byte where we expect
// one, we "replace" the validated continuation bytes we've seen so far with
// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
// behavior. The continuation byte check is included three times in the case
// where all of the continuation bytes for a character exist in the same buffer.
// It is also done this way as a slight performance increase instead of using a
// loop.
function utf8CheckExtraBytes(self, buf, p) {
if ((buf[0] & 0xC0) !== 0x80) {
self.lastNeed = 0;
return '\ufffd';
}
if (self.lastNeed > 1 && buf.length > 1) {
if ((buf[1] & 0xC0) !== 0x80) {
self.lastNeed = 1;
return '\ufffd';
}
if (self.lastNeed > 2 && buf.length > 2) {
if ((buf[2] & 0xC0) !== 0x80) {
self.lastNeed = 2;
return '\ufffd';
}
}
}
}
// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
function utf8FillLast(buf) {
var p = this.lastTotal - this.lastNeed;
var r = utf8CheckExtraBytes(this, buf, p);
if (r !== undefined) return r;
if (this.lastNeed <= buf.length) {
buf.copy(this.lastChar, p, 0, this.lastNeed);
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
}
buf.copy(this.lastChar, p, 0, buf.length);
this.lastNeed -= buf.length;
}
// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
// partial character, the character's bytes are buffered until the required
// number of bytes are available.
function utf8Text(buf, i) {
var total = utf8CheckIncomplete(this, buf, i);
if (!this.lastNeed) return buf.toString('utf8', i);
this.lastTotal = total;
var end = buf.length - (total - this.lastNeed);
buf.copy(this.lastChar, 0, end);
return buf.toString('utf8', i, end);
}
// For UTF-8, a replacement character is added when ending on a partial
// character.
function utf8End(buf) {
var r = buf && buf.length ? this.write(buf) : '';
if (this.lastNeed) return r + '\ufffd';
return r;
}
// UTF-16LE typically needs two bytes per character, but even if we have an even
// number of bytes available, we need to check if we end on a leading/high
// surrogate. In that case, we need to wait for the next two bytes in order to
// decode the last character properly.
function utf16Text(buf, i) {
if ((buf.length - i) % 2 === 0) {
var r = buf.toString('utf16le', i);
if (r) {
var c = r.charCodeAt(r.length - 1);
if (c >= 0xD800 && c <= 0xDBFF) {
this.lastNeed = 2;
this.lastTotal = 4;
this.lastChar[0] = buf[buf.length - 2];
this.lastChar[1] = buf[buf.length - 1];
return r.slice(0, -1);
}
}
return r;
}
this.lastNeed = 1;
this.lastTotal = 2;
this.lastChar[0] = buf[buf.length - 1];
return buf.toString('utf16le', i, buf.length - 1);
}
// For UTF-16LE we do not explicitly append special replacement characters if we
// end on a partial character, we simply let v8 handle that.
function utf16End(buf) {
var r = buf && buf.length ? this.write(buf) : '';
if (this.lastNeed) {
var end = this.lastTotal - this.lastNeed;
return r + this.lastChar.toString('utf16le', 0, end);
}
return r;
}
function base64Text(buf, i) {
var n = (buf.length - i) % 3;
if (n === 0) return buf.toString('base64', i);
this.lastNeed = 3 - n;
this.lastTotal = 3;
if (n === 1) {
this.lastChar[0] = buf[buf.length - 1];
} else {
this.lastChar[0] = buf[buf.length - 2];
this.lastChar[1] = buf[buf.length - 1];
}
return buf.toString('base64', i, buf.length - n);
}
function base64End(buf) {
var r = buf && buf.length ? this.write(buf) : '';
if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.las
tNeed);
return r;
}
// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
function simpleWrite(buf) {
return buf.toString(this.encoding);
}
function simpleEnd(buf) {
return buf && buf.length ? this.write(buf) : '';
}
},{"safe-buffer":143}],160:[function(require,module,exports){
(function (setImmediate,clearImmediate){ (function (setImmediate,clearImmediate){
var nextTick = require('process/browser.js').nextTick; var nextTick = require('process/browser.js').nextTick;
var apply = Function.prototype.apply; var apply = Function.prototype.apply;
var slice = Array.prototype.slice; var slice = Array.prototype.slice;
var immediateIds = {}; var immediateIds = {};
var nextImmediateId = 0; var nextImmediateId = 0;
// DOM APIs, for completeness // DOM APIs, for completeness
exports.setTimeout = function() { exports.setTimeout = function() {
skipping to change at line 24137 skipping to change at line 24139
var combiningChar = '\\u0300-\\u0345\\u0360\\u0361\\u0483-\\u0486\\u0591-\ \u05A1\\u05A3-\\u05B9\\u05BB-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u064B-\\u0652\ \u0670\\u06D6-\\u06E4\\u06E7\\u06E8\\u06EA-\\u06ED\\u0901-\\u0903\\u093C\\u093E- \\u094D\\u0951-\\u0954\\u0962\\u0963\\u0981-\\u0983\\u09BC\\u09BE-\\u09C4\\u09C7 \\u09C8\\u09CB-\\u09CD\\u09D7\\u09E2\\u09E3\\u0A02\\u0A3C\\u0A3E-\\u0A42\\u0A47\ \u0A48\\u0A4B-\\u0A4D\\u0A70\\u0A71\\u0A81-\\u0A83\\u0ABC\\u0ABE-\\u0AC5\\u0AC7- \\u0AC9\\u0ACB-\\u0ACD\\u0B01-\\u0B03\\u0B3C\\u0B3E-\\u0B43\\u0B47\\u0B48\\u0B4B -\\u0B4D\\u0B56\\u0B57\\u0B82\\u0B83\\u0BBE-\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BC D\\u0BD7\\u0C01-\\u0C03\\u0C3E-\\u0C44\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C 56\\u0C82\\u0C83\\u0CBE-\\u0CC4\\u0CC6-\\u0CC8\\u0CCA-\\u0CCD\\u0CD5\\u0CD6\\u0D 02\\u0D03\\u0D3E-\\u0D43\\u0D46-\\u0D48\\u0D4A-\\u0D4D\\u0D57\\u0E31\\u0E34-\\u0 E3A\\u0E47-\\u0E4E\\u0EB1\\u0EB4-\\u0EB9\\u0EBB\\u0EBC\\u0EC8-\\u0ECD\\u0F18\\u0 F19\\u0F35\\u0F37\\u0F39\\u0F3E\\u0F3F\\u0F71-\\u0F84\\u0F86-\\u0F8B\\u0F90-\\u0 F95\\u0F97\\u0F99-\\u0FAD\\u0FB1-\\u0FB7\\u0FB9\\u20D0-\\u20DC\\u20E1\\u302A-\\u 302F\\u3099\\u309A'; var combiningChar = '\\u0300-\\u0345\\u0360\\u0361\\u0483-\\u0486\\u0591-\ \u05A1\\u05A3-\\u05B9\\u05BB-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u064B-\\u0652\ \u0670\\u06D6-\\u06E4\\u06E7\\u06E8\\u06EA-\\u06ED\\u0901-\\u0903\\u093C\\u093E- \\u094D\\u0951-\\u0954\\u0962\\u0963\\u0981-\\u0983\\u09BC\\u09BE-\\u09C4\\u09C7 \\u09C8\\u09CB-\\u09CD\\u09D7\\u09E2\\u09E3\\u0A02\\u0A3C\\u0A3E-\\u0A42\\u0A47\ \u0A48\\u0A4B-\\u0A4D\\u0A70\\u0A71\\u0A81-\\u0A83\\u0ABC\\u0ABE-\\u0AC5\\u0AC7- \\u0AC9\\u0ACB-\\u0ACD\\u0B01-\\u0B03\\u0B3C\\u0B3E-\\u0B43\\u0B47\\u0B48\\u0B4B -\\u0B4D\\u0B56\\u0B57\\u0B82\\u0B83\\u0BBE-\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BC D\\u0BD7\\u0C01-\\u0C03\\u0C3E-\\u0C44\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C 56\\u0C82\\u0C83\\u0CBE-\\u0CC4\\u0CC6-\\u0CC8\\u0CCA-\\u0CCD\\u0CD5\\u0CD6\\u0D 02\\u0D03\\u0D3E-\\u0D43\\u0D46-\\u0D48\\u0D4A-\\u0D4D\\u0D57\\u0E31\\u0E34-\\u0 E3A\\u0E47-\\u0E4E\\u0EB1\\u0EB4-\\u0EB9\\u0EBB\\u0EBC\\u0EC8-\\u0ECD\\u0F18\\u0 F19\\u0F35\\u0F37\\u0F39\\u0F3E\\u0F3F\\u0F71-\\u0F84\\u0F86-\\u0F8B\\u0F90-\\u0 F95\\u0F97\\u0F99-\\u0FAD\\u0FB1-\\u0FB7\\u0FB9\\u20D0-\\u20DC\\u20E1\\u302A-\\u 302F\\u3099\\u309A';
var digit = '0-9\\u0660-\\u0669\\u06F0-\\u06F9\\u0966-\\u096F\\u09E6-\\u09 EF\\u0A66-\\u0A6F\\u0AE6-\\u0AEF\\u0B66-\\u0B6F\\u0BE7-\\u0BEF\\u0C66-\\u0C6F\\u 0CE6-\\u0CEF\\u0D66-\\u0D6F\\u0E50-\\u0E59\\u0ED0-\\u0ED9\\u0F20-\\u0F29'; var digit = '0-9\\u0660-\\u0669\\u06F0-\\u06F9\\u0966-\\u096F\\u09E6-\\u09 EF\\u0A66-\\u0A6F\\u0AE6-\\u0AEF\\u0B66-\\u0B6F\\u0BE7-\\u0BEF\\u0C66-\\u0C6F\\u 0CE6-\\u0CEF\\u0D66-\\u0D6F\\u0E50-\\u0E59\\u0ED0-\\u0ED9\\u0F20-\\u0F29';
var extender = '\\xB7\\u02D0\\u02D1\\u0387\\u0640\\u0E46\\u0EC6\\u3005\\u3 031-\\u3035\\u309D\\u309E\\u30FC-\\u30FE'; var extender = '\\xB7\\u02D0\\u02D1\\u0387\\u0640\\u0E46\\u0EC6\\u3005\\u3 031-\\u3035\\u309D\\u309E\\u30FC-\\u30FE';
var letter = 'A-Za-z\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u0131\\u0134-\\u013E\\u0 141-\\u0148\\u014A-\\u017E\\u0180-\\u01C3\\u01CD-\\u01F0\\u01F4\\u01F5\\u01FA-\\ u0217\\u0250-\\u02A8\\u02BB-\\u02C1\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\ \u03A3-\\u03CE\\u03D0-\\u03D6\\u03DA\\u03DC\\u03DE\\u03E0\\u03E2-\\u03F3\\u0401- \\u040C\\u040E-\\u044F\\u0451-\\u045C\\u045E-\\u0481\\u0490-\\u04C4\\u04C7\\u04C 8\\u04CB\\u04CC\\u04D0-\\u04EB\\u04EE-\\u04F5\\u04F8\\u04F9\\u0531-\\u0556\\u055 9\\u0561-\\u0586\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0621-\\u063A\\u0641-\\u064A\\u0 671-\\u06B7\\u06BA-\\u06BE\\u06C0-\\u06CE\\u06D0-\\u06D3\\u06D5\\u06E5\\u06E6\\u 0905-\\u0939\\u093D\\u0958-\\u0961\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\ u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\ u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\ u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8B\\u0A8D\\ u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\ \u0AE0\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\ \u0B36-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B85-\\u0B8A\\u0B8E-\\u0B90 \\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\ \u0BAE-\\u0BB5\\u0BB7-\\u0BB9\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2 A-\\u0C33\\u0C35-\\u0C39\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0 CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CDE\\u0CE0\\u0CE1\\u0D05-\\u0D0C\\u0D0E-\\u 0D10\\u0D12-\\u0D28\\u0D2A-\\u0D39\\u0D60\\u0D61\\u0E01-\\u0E2E\\u0E30\\u0E32\\u 0E33\\u0E40-\\u0E45\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0 E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD\\u0EAE\\u0E B0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0F40-\\u0F47\\u0F49-\\u0F69\\u10A0-\\u1 0C5\\u10D0-\\u10F6\\u1100\\u1102\\u1103\\u1105-\\u1107\\u1109\\u110B\\u110C\\u11 0E-\\u1112\\u113C\\u113E\\u1140\\u114C\\u114E\\u1150\\u1154\\u1155\\u1159\\u115F -\\u1161\\u1163\\u1165\\u1167\\u1169\\u116D\\u116E\\u1172\\u1173\\u1175\\u119E\\ u11A8\\u11AB\\u11AE\\u11AF\\u11B7\\u11B8\\u11BA\\u11BC-\\u11C2\\u11EB\\u11F0\\u1 1F9\\u1E00-\\u1E9B\\u1EA0-\\u1EF9\\u1F00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\ u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\ \u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FD B\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2126\\u212A\\u212B\\u212E\\u218 0-\\u2182\\u3007\\u3021-\\u3029\\u3041-\\u3094\\u30A1-\\u30FA\\u3105-\\u312C\\u4 E00-\\u9FA5\\uAC00-\\uD7A3'; var letter = 'A-Za-z\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u0131\\u0134-\\u013E\\u0 141-\\u0148\\u014A-\\u017E\\u0180-\\u01C3\\u01CD-\\u01F0\\u01F4\\u01F5\\u01FA-\\ u0217\\u0250-\\u02A8\\u02BB-\\u02C1\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\ \u03A3-\\u03CE\\u03D0-\\u03D6\\u03DA\\u03DC\\u03DE\\u03E0\\u03E2-\\u03F3\\u0401- \\u040C\\u040E-\\u044F\\u0451-\\u045C\\u045E-\\u0481\\u0490-\\u04C4\\u04C7\\u04C 8\\u04CB\\u04CC\\u04D0-\\u04EB\\u04EE-\\u04F5\\u04F8\\u04F9\\u0531-\\u0556\\u055 9\\u0561-\\u0586\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0621-\\u063A\\u0641-\\u064A\\u0 671-\\u06B7\\u06BA-\\u06BE\\u06C0-\\u06CE\\u06D0-\\u06D3\\u06D5\\u06E5\\u06E6\\u 0905-\\u0939\\u093D\\u0958-\\u0961\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\ u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\ u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\ u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8B\\u0A8D\\ u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\ \u0AE0\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\ \u0B36-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B85-\\u0B8A\\u0B8E-\\u0B90 \\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\ \u0BAE-\\u0BB5\\u0BB7-\\u0BB9\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2 A-\\u0C33\\u0C35-\\u0C39\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0 CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CDE\\u0CE0\\u0CE1\\u0D05-\\u0D0C\\u0D0E-\\u 0D10\\u0D12-\\u0D28\\u0D2A-\\u0D39\\u0D60\\u0D61\\u0E01-\\u0E2E\\u0E30\\u0E32\\u 0E33\\u0E40-\\u0E45\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0 E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD\\u0EAE\\u0E B0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0F40-\\u0F47\\u0F49-\\u0F69\\u10A0-\\u1 0C5\\u10D0-\\u10F6\\u1100\\u1102\\u1103\\u1105-\\u1107\\u1109\\u110B\\u110C\\u11 0E-\\u1112\\u113C\\u113E\\u1140\\u114C\\u114E\\u1150\\u1154\\u1155\\u1159\\u115F -\\u1161\\u1163\\u1165\\u1167\\u1169\\u116D\\u116E\\u1172\\u1173\\u1175\\u119E\\ u11A8\\u11AB\\u11AE\\u11AF\\u11B7\\u11B8\\u11BA\\u11BC-\\u11C2\\u11EB\\u11F0\\u1 1F9\\u1E00-\\u1E9B\\u1EA0-\\u1EF9\\u1F00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\ u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\ \u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FD B\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2126\\u212A\\u212B\\u212E\\u218 0-\\u2182\\u3007\\u3021-\\u3029\\u3041-\\u3094\\u30A1-\\u30FA\\u3105-\\u312C\\u4 E00-\\u9FA5\\uAC00-\\uD7A3';
var ncname = '[' + letter + '_][' + letter + digit + '\\.\\-_' + combining Char + extender + ']*'; var ncname = '[' + letter + '_][' + letter + digit + '\\.\\-_' + combining Char + extender + ']*';
return '((?:' + ncname + '\\:)?' + ncname + ')'; return '((?:' + ncname + '\\:)?' + ncname + ')';
})(), })(),
startTagOpen = new RegExp('^<' + qnameCapture), startTagOpen = new RegExp('^<' + qnameCapture),
startTagClose = /^\s*(\/?)>/, startTagClose = /^\s*(\/?)>/,
endTag = new RegExp('^<\\/' + qnameCapture + '[^>]*>'), endTag = new RegExp('^<\\/' + qnameCapture + '[^>]*>'),
doctype = /^<!DOCTYPE\s[^>]+>/i; doctype = /^<!DOCTYPE\s?[^>]+>/i;
var IS_REGEX_CAPTURING_BROKEN = false; var IS_REGEX_CAPTURING_BROKEN = false;
'x'.replace(/x(.)?/g, function(m, g) { 'x'.replace(/x(.)?/g, function(m, g) {
IS_REGEX_CAPTURING_BROKEN = g === ''; IS_REGEX_CAPTURING_BROKEN = g === '';
}); });
// Empty Elements // Empty Elements
var empty = makeMap('area,base,basefont,br,col,embed,frame,hr,img,input,isindex, keygen,link,meta,param,source,track,wbr'); var empty = makeMap('area,base,basefont,br,col,embed,frame,hr,img,input,isindex, keygen,link,meta,param,source,track,wbr');
// Inline Elements // Inline Elements
skipping to change at line 24259 skipping to change at line 24261
} }
// Start tag: // Start tag:
var startTagMatch = parseStartTag(html); var startTagMatch = parseStartTag(html);
if (startTagMatch) { if (startTagMatch) {
html = startTagMatch.rest; html = startTagMatch.rest;
handleStartTag(startTagMatch); handleStartTag(startTagMatch);
prevTag = startTagMatch.tagName.toLowerCase(); prevTag = startTagMatch.tagName.toLowerCase();
continue; continue;
} }
// Treat `<` as text
if (handler.continueOnParseError) {
textEnd = html.indexOf('<', 1);
}
} }
var text; var text;
if (textEnd >= 0) { if (textEnd >= 0) {
text = html.substring(0, textEnd); text = html.substring(0, textEnd);
html = html.substring(textEnd); html = html.substring(textEnd);
} }
else { else {
text = html; text = html;
html = ''; html = '';
skipping to change at line 24290 skipping to change at line 24297
} }
else { else {
nextTag = ''; nextTag = '';
} }
} }
if (handler.chars) { if (handler.chars) {
handler.chars(text, prevTag, nextTag); handler.chars(text, prevTag, nextTag);
} }
prevTag = ''; prevTag = '';
} }
else { else {
var stackedTag = lastTag.toLowerCase(); var stackedTag = lastTag.toLowerCase();
var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegEx p('([\\s\\S]*?)</' + stackedTag + '[^>]*>', 'i')); var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegEx p('([\\s\\S]*?)</' + stackedTag + '[^>]*>', 'i'));
html = html.replace(reStackedTag, function(all, text) { html = html.replace(reStackedTag, function(all, text) {
if (stackedTag !== 'script' && stackedTag !== 'style' && stackedTag !== 'noscript') { if (stackedTag !== 'script' && stackedTag !== 'style' && stackedTag !== 'noscript') {
text = text text = text
.replace(/<!--([\s\S]*?)-->/g, '$1') .replace(/<!--([\s\S]*?)-->/g, '$1')
.replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1'); .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
skipping to change at line 25046 skipping to change at line 25052
}).join(', '); }).join(', ');
} }
else if (isMetaViewport(tag, attrs) && attrName === 'content') { else if (isMetaViewport(tag, attrs) && attrName === 'content') {
attrValue = attrValue.replace(/\s+/g, '').replace(/[0-9]+\.[0-9]+/g, functio n(numString) { attrValue = attrValue.replace(/\s+/g, '').replace(/[0-9]+\.[0-9]+/g, functio n(numString) {
// "0.90000" -> "0.9" // "0.90000" -> "0.9"
// "1.0" -> "1" // "1.0" -> "1"
// "1.0001" -> "1.0001" (unchanged) // "1.0001" -> "1.0001" (unchanged)
return (+numString).toString(); return (+numString).toString();
}); });
} }
else if (isContentSecurityPolicy(tag, attrs) && attrName.toLowerCase() === 'co
ntent') {
return collapseWhitespaceAll(attrValue);
}
else if (options.customAttrCollapse && options.customAttrCollapse.test(attrNam e)) { else if (options.customAttrCollapse && options.customAttrCollapse.test(attrNam e)) {
attrValue = attrValue.replace(/\n+|\r+|\s{2,}/g, ''); attrValue = attrValue.replace(/\n+|\r+|\s{2,}/g, '');
} }
else if (tag === 'script' && attrName === 'type') { else if (tag === 'script' && attrName === 'type') {
attrValue = trimWhitespace(attrValue.replace(/\s*;\s*/g, ';')); attrValue = trimWhitespace(attrValue.replace(/\s*;\s*/g, ';'));
} }
else if (isMediaQuery(tag, attrs, attrName)) { else if (isMediaQuery(tag, attrs, attrName)) {
attrValue = trimWhitespace(attrValue); attrValue = trimWhitespace(attrValue);
return options.minifyCSS(attrValue, 'media'); return options.minifyCSS(attrValue, 'media');
} }
skipping to change at line 25070 skipping to change at line 25079
if (tag !== 'meta') { if (tag !== 'meta') {
return false; return false;
} }
for (var i = 0, len = attrs.length; i < len; i++) { for (var i = 0, len = attrs.length; i < len; i++) {
if (attrs[i].name === 'name' && attrs[i].value === 'viewport') { if (attrs[i].name === 'name' && attrs[i].value === 'viewport') {
return true; return true;
} }
} }
} }
function isContentSecurityPolicy(tag, attrs) {
if (tag !== 'meta') {
return false;
}
for (var i = 0, len = attrs.length; i < len; i++) {
if (attrs[i].name.toLowerCase() === 'http-equiv' && attrs[i].value.toLowerCa
se() === 'content-security-policy') {
return true;
}
}
}
function ignoreCSS(id) { function ignoreCSS(id) {
return '/* clean-css ignore:start */' + id + '/* clean-css ignore:end */'; return '/* clean-css ignore:start */' + id + '/* clean-css ignore:end */';
} }
// Wrap CSS declarations for CleanCSS > 3.x // Wrap CSS declarations for CleanCSS > 3.x
// See https://github.com/jakubpawlowicz/clean-css/issues/418 // See https://github.com/jakubpawlowicz/clean-css/issues/418
function wrapCSS(text, type) { function wrapCSS(text, type) {
switch (type) { switch (type) {
case 'inline': case 'inline':
return '*{' + text + '}'; return '*{' + text + '}';
skipping to change at line 25599 skipping to change at line 25619
var customFragments = options.ignoreCustomFragments.map(function(re) { var customFragments = options.ignoreCustomFragments.map(function(re) {
return re.source; return re.source;
}); });
if (customFragments.length) { if (customFragments.length) {
var reCustomIgnore = new RegExp('\\s*(?:' + customFragments.join('|') + ')+\ \s*', 'g'); var reCustomIgnore = new RegExp('\\s*(?:' + customFragments.join('|') + ')+\ \s*', 'g');
// temporarily replace custom ignored fragments with unique attributes // temporarily replace custom ignored fragments with unique attributes
value = value.replace(reCustomIgnore, function(match) { value = value.replace(reCustomIgnore, function(match) {
if (!uidAttr) { if (!uidAttr) {
uidAttr = uniqueId(value); uidAttr = uniqueId(value);
uidPattern = new RegExp('(\\s*)' + uidAttr + '([0-9]+)(\\s*)', 'g'); uidPattern = new RegExp('(\\s*)' + uidAttr + '([0-9]+)' + uidAttr + '(\\ s*)', 'g');
if (options.minifyCSS) { if (options.minifyCSS) {
options.minifyCSS = (function(fn) { options.minifyCSS = (function(fn) {
return function(text, type) { return function(text, type) {
text = text.replace(uidPattern, function(match, prefix, index) { text = text.replace(uidPattern, function(match, prefix, index) {
var chunks = ignoredCustomMarkupChunks[+index]; var chunks = ignoredCustomMarkupChunks[+index];
return chunks[1] + uidAttr + index + chunks[2]; return chunks[1] + uidAttr + index + uidAttr + chunks[2];
}); });
var ids = []; var ids = [];
new CleanCSS().minify(wrapCSS(text, type)).warnings.forEach(functi on(warning) { new CleanCSS().minify(wrapCSS(text, type)).warnings.forEach(functi on(warning) {
var match = uidPattern.exec(warning); var match = uidPattern.exec(warning);
if (match) { if (match) {
var id = uidAttr + match[2]; var id = uidAttr + match[2] + uidAttr;
text = text.replace(id, ignoreCSS(id)); text = text.replace(id, ignoreCSS(id));
ids.push(id); ids.push(id);
} }
}); });
text = fn(text, type); text = fn(text, type);
ids.forEach(function(id) { ids.forEach(function(id) {
text = text.replace(ignoreCSS(id), id); text = text.replace(ignoreCSS(id), id);
}); });
return text; return text;
}; };
})(options.minifyCSS); })(options.minifyCSS);
} }
if (options.minifyJS) { if (options.minifyJS) {
options.minifyJS = (function(fn) { options.minifyJS = (function(fn) {
return function(text, type) { return function(text, type) {
return fn(text.replace(uidPattern, function(match, prefix, index) { return fn(text.replace(uidPattern, function(match, prefix, index) {
var chunks = ignoredCustomMarkupChunks[+index]; var chunks = ignoredCustomMarkupChunks[+index];
return chunks[1] + uidAttr + index + chunks[2]; return chunks[1] + uidAttr + index + uidAttr + chunks[2];
}), type); }), type);
}; };
})(options.minifyJS); })(options.minifyJS);
} }
} }
var token = uidAttr + ignoredCustomMarkupChunks.length; var token = uidAttr + ignoredCustomMarkupChunks.length + uidAttr;
ignoredCustomMarkupChunks.push(/^(\s*)[\s\S]*?(\s*)$/.exec(match)); ignoredCustomMarkupChunks.push(/^(\s*)[\s\S]*?(\s*)$/.exec(match));
return '\t' + token + '\t'; return '\t' + token + '\t';
}); });
} }
if (options.sortAttributes && typeof options.sortAttributes !== 'function' || if (options.sortAttributes && typeof options.sortAttributes !== 'function' ||
options.sortClassName && typeof options.sortClassName !== 'function') { options.sortClassName && typeof options.sortClassName !== 'function') {
createSortFns(value, options, uidIgnore, uidAttr); createSortFns(value, options, uidIgnore, uidAttr);
} }
skipping to change at line 25700 skipping to change at line 25720
var item = buffer[buffer.length - 1]; var item = buffer[buffer.length - 1];
if (/^(?:<!|$)/.test(item) && item.indexOf(uidIgnore) === -1) { if (/^(?:<!|$)/.test(item) && item.indexOf(uidIgnore) === -1) {
charsIndex--; charsIndex--;
} }
} }
trimTrailingWhitespace(charsIndex, nextTag); trimTrailingWhitespace(charsIndex, nextTag);
} }
new HTMLParser(value, { new HTMLParser(value, {
partialMarkup: partialMarkup, partialMarkup: partialMarkup,
continueOnParseError: options.continueOnParseError,
customAttrAssign: options.customAttrAssign,
customAttrSurround: options.customAttrSurround,
html5: options.html5, html5: options.html5,
start: function(tag, attrs, unary, unarySlash, autoGenerated) { start: function(tag, attrs, unary, unarySlash, autoGenerated) {
if (tag.toLowerCase() === 'svg') { if (tag.toLowerCase() === 'svg') {
options = Object.create(options); options = Object.create(options);
options.caseSensitive = true; options.caseSensitive = true;
options.keepClosingSlash = true; options.keepClosingSlash = true;
options.name = identity; options.name = identity;
} }
tag = options.name(tag); tag = options.name(tag);
skipping to change at line 25973 skipping to change at line 25996
text = prefix + text + suffix; text = prefix + text + suffix;
} }
if (options.removeOptionalTags && text) { if (options.removeOptionalTags && text) {
// preceding comments suppress tag omissions // preceding comments suppress tag omissions
optionalStartTag = ''; optionalStartTag = '';
optionalEndTag = ''; optionalEndTag = '';
} }
buffer.push(text); buffer.push(text);
}, },
doctype: function(doctype) { doctype: function(doctype) {
buffer.push(options.useShortDoctype ? '<!doctype html>' : collapseWhitespa buffer.push(options.useShortDoctype ? '<!doctype' +
ceAll(doctype)); (options.removeTagWhitespace ? '' : ' ') + 'html>' :
}, collapseWhitespaceAll(doctype));
customAttrAssign: options.customAttrAssign, }
customAttrSurround: options.customAttrSurround
}); });
if (options.removeOptionalTags) { if (options.removeOptionalTags) {
// <html> may be omitted if first thing inside is not comment // <html> may be omitted if first thing inside is not comment
// <head> or <body> may be omitted if empty // <head> or <body> may be omitted if empty
if (topLevelTags(optionalStartTag)) { if (topLevelTags(optionalStartTag)) {
removeStartTag(); removeStartTag();
} }
// except for </dt> or </thead>, end tags may be omitted if no more content in parent element // except for </dt> or </thead>, end tags may be omitted if no more content in parent element
if (optionalEndTag && !trailingTags(optionalEndTag)) { if (optionalEndTag && !trailingTags(optionalEndTag)) {
skipping to change at line 26061 skipping to change at line 26084