Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: node_modules/punycode.js

Issue 29336753: Issue 3671 - Split out contentBlockerList API (Closed)
Patch Set: Created Feb. 20, 2016, 9:59 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: node_modules/punycode.js
diff --git a/node_modules/punycode.js b/node_modules/punycode.js
new file mode 100644
index 0000000000000000000000000000000000000000..3fc93e12cd31f69cacdda4c0f270baaf1cafb1d3
--- /dev/null
+++ b/node_modules/punycode.js
@@ -0,0 +1,337 @@
+/*
+ * This file is part of Adblock Plus <https://adblockplus.org/>,
Sebastian Noack 2016/02/21 02:21:08 Nice.js already comes with punycode. So does adblo
kzar 2016/02/21 11:31:19 Done.
+ * Copyright (C) 2006-2016 Eyeo GmbH
+ *
+ * Adblock Plus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Adblock Plus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+//
+// This file has been generated automatically, relevant repositories:
+// * https://hg.adblockplus.org/jshydra/
+//
+
+;
+(function(root)
+{
+ var freeExports = typeof exports == "object" && exports;
+ var freeModule = typeof module == "object" && module && module.exports == freeExports && module;
+ var freeGlobal = typeof global == "object" && global;
+ if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)
+ {
+ root = freeGlobal;
+ }
+ var punycode, maxInt = 2147483647,
+ base = 36,
+ tMin = 1,
+ tMax = 26,
+ skew = 38,
+ damp = 700,
+ initialBias = 72,
+ initialN = 128,
+ delimiter = "-",
+ regexPunycode = /^xn--/,
+ regexNonASCII = /[^ -~]/,
+ regexSeparators = /\x2E|\u3002|\uFF0E|\uFF61/g,
+ errors = {
+ "overflow": "Overflow: input needs wider integers to process",
+ "not-basic": "Illegal input >= 0x80 (not a basic code point)",
+ "invalid-input": "Invalid input"
+ }, baseMinusTMin = base - tMin,
+ floor = Math.floor,
+ stringFromCharCode = String.fromCharCode,
+ key;
+
+ function error(type)
+ {
+ throw RangeError(errors[type]);
+ }
+
+ function map(array, fn)
+ {
+ var length = array.length;
+ while (length--)
+ {
+ array[length] = fn(array[length]);
+ }
+ return array;
+ }
+
+ function mapDomain(string, fn)
+ {
+ return map(string.split(regexSeparators), fn).join(".");
+ }
+
+ function ucs2decode(string)
+ {
+ var output = [],
+ counter = 0,
+ length = string.length,
+ value, extra;
+ while (counter < length)
+ {
+ value = string.charCodeAt(counter++);
+ if (value >= 55296 && value <= 56319 && counter < length)
+ {
+ extra = string.charCodeAt(counter++);
+ if ((extra & 64512) == 56320)
+ {
+ output.push(((value & 1023) << 10) + (extra & 1023) + 65536);
+ }
+ else
+ {
+ output.push(value);
+ counter--;
+ }
+ }
+ else
+ {
+ output.push(value);
+ }
+ }
+ return output;
+ }
+
+ function ucs2encode(array)
+ {
+ return map(array, function(value)
+ {
+ var output = "";
+ if (value > 65535)
+ {
+ value -= 65536;
+ output += stringFromCharCode(value >>> 10 & 1023 | 55296);
+ value = 56320 | value & 1023;
+ }
+ output += stringFromCharCode(value);
+ return output;
+ }).join("");
+ }
+
+ function basicToDigit(codePoint)
+ {
+ if (codePoint - 48 < 10)
+ {
+ return codePoint - 22;
+ }
+ if (codePoint - 65 < 26)
+ {
+ return codePoint - 65;
+ }
+ if (codePoint - 97 < 26)
+ {
+ return codePoint - 97;
+ }
+ return base;
+ }
+
+ function digitToBasic(digit, flag)
+ {
+ return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
+ }
+
+ function adapt(delta, numPoints, firstTime)
+ {
+ var k = 0;
+ delta = firstTime ? floor(delta / damp) : delta >> 1;
+ delta += floor(delta / numPoints);
+ for (; delta > baseMinusTMin * tMax >> 1; k += base)
+ {
+ delta = floor(delta / baseMinusTMin);
+ }
+ return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
+ }
+
+ function decode(input)
+ {
+ var output = [],
+ inputLength = input.length,
+ out, i = 0,
+ n = initialN,
+ bias = initialBias,
+ basic, j, index, oldi, w, k, digit, t, length, baseMinusT;
+ basic = input.lastIndexOf(delimiter);
+ if (basic < 0)
+ {
+ basic = 0;
+ }
+ for (j = 0; j < basic; ++j)
+ {
+ if (input.charCodeAt(j) >= 128)
+ {
+ error("not-basic");
+ }
+ output.push(input.charCodeAt(j));
+ }
+ for (index = basic > 0 ? basic + 1 : 0; index < inputLength;)
+ {
+ for ((oldi = i, w = 1, k = base);; k += base)
+ {
+ if (index >= inputLength)
+ {
+ error("invalid-input");
+ }
+ digit = basicToDigit(input.charCodeAt(index++));
+ if (digit >= base || digit > floor((maxInt - i) / w))
+ {
+ error("overflow");
+ }
+ i += digit * w;
+ t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
+ if (digit < t)
+ {
+ break;
+ }
+ baseMinusT = base - t;
+ if (w > floor(maxInt / baseMinusT))
+ {
+ error("overflow");
+ }
+ w *= baseMinusT;
+ }
+ out = output.length + 1;
+ bias = adapt(i - oldi, out, oldi == 0);
+ if (floor(i / out) > maxInt - n)
+ {
+ error("overflow");
+ }
+ n += floor(i / out);
+ i %= out;
+ output.splice(i++, 0, n);
+ }
+ return ucs2encode(output);
+ }
+
+ function encode(input)
+ {
+ var n, delta, handledCPCount, basicLength, bias, j, m, q, k, t, currentValue, output = [],
+ inputLength, handledCPCountPlusOne, baseMinusT, qMinusT;
+ input = ucs2decode(input);
+ inputLength = input.length;
+ n = initialN;
+ delta = 0;
+ bias = initialBias;
+ for (j = 0; j < inputLength; ++j)
+ {
+ currentValue = input[j];
+ if (currentValue < 128)
+ {
+ output.push(stringFromCharCode(currentValue));
+ }
+ }
+ handledCPCount = basicLength = output.length;
+ if (basicLength)
+ {
+ output.push(delimiter);
+ }
+ while (handledCPCount < inputLength)
+ {
+ for ((m = maxInt, j = 0); j < inputLength; ++j)
+ {
+ currentValue = input[j];
+ if (currentValue >= n && currentValue < m)
+ {
+ m = currentValue;
+ }
+ }
+ handledCPCountPlusOne = handledCPCount + 1;
+ if (m - n > floor((maxInt - delta) / handledCPCountPlusOne))
+ {
+ error("overflow");
+ }
+ delta += (m - n) * handledCPCountPlusOne;
+ n = m;
+ for (j = 0; j < inputLength; ++j)
+ {
+ currentValue = input[j];
+ if (currentValue < n && ++delta > maxInt)
+ {
+ error("overflow");
+ }
+ if (currentValue == n)
+ {
+ for ((q = delta, k = base);; k += base)
+ {
+ t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
+ if (q < t)
+ {
+ break;
+ }
+ qMinusT = q - t;
+ baseMinusT = base - t;
+ output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)));
+ q = floor(qMinusT / baseMinusT);
+ }
+ output.push(stringFromCharCode(digitToBasic(q, 0)));
+ bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
+ delta = 0;
+ ++handledCPCount;
+ }
+ }++delta;
+ ++n;
+ }
+ return output.join("");
+ }
+
+ function toUnicode(domain)
+ {
+ return mapDomain(domain, function(string)
+ {
+ return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
+ });
+ }
+
+ function toASCII(domain)
+ {
+ return mapDomain(domain, function(string)
+ {
+ return regexNonASCII.test(string) ? "xn--" + encode(string) : string;
+ });
+ }
+ punycode = {
+ "version": "1.2.3",
+ "ucs2": {
+ "decode": ucs2decode,
+ "encode": ucs2encode
+ },
+ "decode": decode,
+ "encode": encode,
+ "toASCII": toASCII,
+ "toUnicode": toUnicode
+ };
+ if (typeof define == "function" && typeof define.amd == "object" && define.amd)
+ {
+ define(function()
+ {
+ return punycode;
+ });
+ }
+ else if (freeExports && !freeExports.nodeType)
+ {
+ if (freeModule)
+ {
+ freeModule.exports = punycode;
+ }
+ else
+ {
+ for (key in punycode)
+ {
+ punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
+ }
+ }
+ }
+ else
+ {
+ root.punycode = punycode;
+ }
+})(this);
+

Powered by Google App Engine
This is Rietveld