Team Ai
Datasetpublic

Brunobkr/llama.cpp_AlgMor24_github

ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes3.1kdownloads
url-state-machine.js1304 linesDownload Raw Back to lib
1"use strict";2const punycode = require("punycode");3const tr46 = require("tr46");4 5const infra = require("./infra");6const { percentEncode, percentDecode } = require("./urlencoded");7 8const specialSchemes = {9  ftp: 21,10  file: null,11  http: 80,12  https: 443,13  ws: 80,14  wss: 44315};16 17const failure = Symbol("failure");18 19function countSymbols(str) {20  return punycode.ucs2.decode(str).length;21}22 23function at(input, idx) {24  const c = input[idx];25  return isNaN(c) ? undefined : String.fromCodePoint(c);26}27 28function isSingleDot(buffer) {29  return buffer === "." || buffer.toLowerCase() === "%2e";30}31 32function isDoubleDot(buffer) {33  buffer = buffer.toLowerCase();34  return buffer === ".." || buffer === "%2e." || buffer === ".%2e" || buffer === "%2e%2e";35}36 37function isWindowsDriveLetterCodePoints(cp1, cp2) {38  return infra.isASCIIAlpha(cp1) && (cp2 === 58 || cp2 === 124);39}40 41function isWindowsDriveLetterString(string) {42  return string.length === 2 && infra.isASCIIAlpha(string.codePointAt(0)) && (string[1] === ":" || string[1] === "|");43}44 45function isNormalizedWindowsDriveLetterString(string) {46  return string.length === 2 && infra.isASCIIAlpha(string.codePointAt(0)) && string[1] === ":";47}48 49function containsForbiddenHostCodePoint(string) {50  return string.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|%|\/|:|\?|@|\[|\\|\]/) !== -1;51}52 53function containsForbiddenHostCodePointExcludingPercent(string) {54  return string.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|\/|:|\?|@|\[|\\|\]/) !== -1;55}56 57function isSpecialScheme(scheme) {58  return specialSchemes[scheme] !== undefined;59}60 61function isSpecial(url) {62  return isSpecialScheme(url.scheme);63}64 65function isNotSpecial(url) {66  return !isSpecialScheme(url.scheme);67}68 69function defaultPort(scheme) {70  return specialSchemes[scheme];71}72 73function utf8PercentEncode(c) {74  const buf = Buffer.from(c);75 76  let str = "";77 78  for (let i = 0; i < buf.length; ++i) {79    str += percentEncode(buf[i]);80  }81 82  return str;83}84 85function isC0ControlPercentEncode(c) {86  return c <= 0x1F || c > 0x7E;87}88 89const extraUserinfoPercentEncodeSet =90  new Set([47, 58, 59, 61, 64, 91, 92, 93, 94, 124]);91function isUserinfoPercentEncode(c) {92  return isPathPercentEncode(c) || extraUserinfoPercentEncodeSet.has(c);93}94 95const extraFragmentPercentEncodeSet = new Set([32, 34, 60, 62, 96]);96function isFragmentPercentEncode(c) {97  return isC0ControlPercentEncode(c) || extraFragmentPercentEncodeSet.has(c);98}99 100const extraPathPercentEncodeSet = new Set([35, 63, 123, 125]);101function isPathPercentEncode(c) {102  return isFragmentPercentEncode(c) || extraPathPercentEncodeSet.has(c);103}104 105function percentEncodeChar(c, encodeSetPredicate) {106  const cStr = String.fromCodePoint(c);107 108  if (encodeSetPredicate(c)) {109    return utf8PercentEncode(cStr);110  }111 112  return cStr;113}114 115function parseIPv4Number(input) {116  let R = 10;117 118  if (input.length >= 2 && input.charAt(0) === "0" && input.charAt(1).toLowerCase() === "x") {119    input = input.substring(2);120    R = 16;121  } else if (input.length >= 2 && input.charAt(0) === "0") {122    input = input.substring(1);123    R = 8;124  }125 126  if (input === "") {127    return 0;128  }129 130  let regex = /[^0-7]/;131  if (R === 10) {132    regex = /[^0-9]/;133  }134  if (R === 16) {135    regex = /[^0-9A-Fa-f]/;136  }137 138  if (regex.test(input)) {139    return failure;140  }141 142  return parseInt(input, R);143}144 145function parseIPv4(input) {146  const parts = input.split(".");147  if (parts[parts.length - 1] === "") {148    if (parts.length > 1) {149      parts.pop();150    }151  }152 153  if (parts.length > 4) {154    return input;155  }156 157  const numbers = [];158  for (const part of parts) {159    if (part === "") {160      return input;161    }162    const n = parseIPv4Number(part);163    if (n === failure) {164      return input;165    }166 167    numbers.push(n);168  }169 170  for (let i = 0; i < numbers.length - 1; ++i) {171    if (numbers[i] > 255) {172      return failure;173    }174  }175  if (numbers[numbers.length - 1] >= Math.pow(256, 5 - numbers.length)) {176    return failure;177  }178 179  let ipv4 = numbers.pop();180  let counter = 0;181 182  for (const n of numbers) {183    ipv4 += n * Math.pow(256, 3 - counter);184    ++counter;185  }186 187  return ipv4;188}189 190function serializeIPv4(address) {191  let output = "";192  let n = address;193 194  for (let i = 1; i <= 4; ++i) {195    output = String(n % 256) + output;196    if (i !== 4) {197      output = "." + output;198    }199    n = Math.floor(n / 256);200  }201 202  return output;203}204 205function parseIPv6(input) {206  const address = [0, 0, 0, 0, 0, 0, 0, 0];207  let pieceIndex = 0;208  let compress = null;209  let pointer = 0;210 211  input = punycode.ucs2.decode(input);212 213  if (input[pointer] === 58) {214    if (input[pointer + 1] !== 58) {215      return failure;216    }217 218    pointer += 2;219    ++pieceIndex;220    compress = pieceIndex;221  }222 223  while (pointer < input.length) {224    if (pieceIndex === 8) {225      return failure;226    }227 228    if (input[pointer] === 58) {229      if (compress !== null) {230        return failure;231      }232      ++pointer;233      ++pieceIndex;234      compress = pieceIndex;235      continue;236    }237 238    let value = 0;239    let length = 0;240 241    while (length < 4 && infra.isASCIIHex(input[pointer])) {242      value = value * 0x10 + parseInt(at(input, pointer), 16);243      ++pointer;244      ++length;245    }246 247    if (input[pointer] === 46) {248      if (length === 0) {249        return failure;250      }251 252      pointer -= length;253 254      if (pieceIndex > 6) {255        return failure;256      }257 258      let numbersSeen = 0;259 260      while (input[pointer] !== undefined) {261        let ipv4Piece = null;262 263        if (numbersSeen > 0) {264          if (input[pointer] === 46 && numbersSeen < 4) {265            ++pointer;266          } else {267            return failure;268          }269        }270 271        if (!infra.isASCIIDigit(input[pointer])) {272          return failure;273        }274 275        while (infra.isASCIIDigit(input[pointer])) {276          const number = parseInt(at(input, pointer));277          if (ipv4Piece === null) {278            ipv4Piece = number;279          } else if (ipv4Piece === 0) {280            return failure;281          } else {282            ipv4Piece = ipv4Piece * 10 + number;283          }284          if (ipv4Piece > 255) {285            return failure;286          }287          ++pointer;288        }289 290        address[pieceIndex] = address[pieceIndex] * 0x100 + ipv4Piece;291 292        ++numbersSeen;293 294        if (numbersSeen === 2 || numbersSeen === 4) {295          ++pieceIndex;296        }297      }298 299      if (numbersSeen !== 4) {300        return failure;301      }302 303      break;304    } else if (input[pointer] === 58) {305      ++pointer;306      if (input[pointer] === undefined) {307        return failure;308      }309    } else if (input[pointer] !== undefined) {310      return failure;311    }312 313    address[pieceIndex] = value;314    ++pieceIndex;315  }316 317  if (compress !== null) {318    let swaps = pieceIndex - compress;319    pieceIndex = 7;320    while (pieceIndex !== 0 && swaps > 0) {321      const temp = address[compress + swaps - 1];322      address[compress + swaps - 1] = address[pieceIndex];323      address[pieceIndex] = temp;324      --pieceIndex;325      --swaps;326    }327  } else if (compress === null && pieceIndex !== 8) {328    return failure;329  }330 331  return address;332}333 334function serializeIPv6(address) {335  let output = "";336  const seqResult = findLongestZeroSequence(address);337  const compress = seqResult.idx;338  let ignore0 = false;339 340  for (let pieceIndex = 0; pieceIndex <= 7; ++pieceIndex) {341    if (ignore0 && address[pieceIndex] === 0) {342      continue;343    } else if (ignore0) {344      ignore0 = false;345    }346 347    if (compress === pieceIndex) {348      const separator = pieceIndex === 0 ? "::" : ":";349      output += separator;350      ignore0 = true;351      continue;352    }353 354    output += address[pieceIndex].toString(16);355 356    if (pieceIndex !== 7) {357      output += ":";358    }359  }360 361  return output;362}363 364function parseHost(input, isNotSpecialArg = false) {365  if (input[0] === "[") {366    if (input[input.length - 1] !== "]") {367      return failure;368    }369 370    return parseIPv6(input.substring(1, input.length - 1));371  }372 373  if (isNotSpecialArg) {374    return parseOpaqueHost(input);375  }376 377  const domain = percentDecode(Buffer.from(input)).toString();378  const asciiDomain = domainToASCII(domain);379  if (asciiDomain === failure) {380    return failure;381  }382 383  if (containsForbiddenHostCodePoint(asciiDomain)) {384    return failure;385  }386 387  const ipv4Host = parseIPv4(asciiDomain);388  if (typeof ipv4Host === "number" || ipv4Host === failure) {389    return ipv4Host;390  }391 392  return asciiDomain;393}394 395function parseOpaqueHost(input) {396  if (containsForbiddenHostCodePointExcludingPercent(input)) {397    return failure;398  }399 400  let output = "";401  const decoded = punycode.ucs2.decode(input);402  for (let i = 0; i < decoded.length; ++i) {403    output += percentEncodeChar(decoded[i], isC0ControlPercentEncode);404  }405  return output;406}407 408function findLongestZeroSequence(arr) {409  let maxIdx = null;410  let maxLen = 1; // only find elements > 1411  let currStart = null;412  let currLen = 0;413 414  for (let i = 0; i < arr.length; ++i) {415    if (arr[i] !== 0) {416      if (currLen > maxLen) {417        maxIdx = currStart;418        maxLen = currLen;419      }420 421      currStart = null;422      currLen = 0;423    } else {424      if (currStart === null) {425        currStart = i;426      }427      ++currLen;428    }429  }430 431  // if trailing zeros432  if (currLen > maxLen) {433    maxIdx = currStart;434    maxLen = currLen;435  }436 437  return {438    idx: maxIdx,439    len: maxLen440  };441}442 443function serializeHost(host) {444  if (typeof host === "number") {445    return serializeIPv4(host);446  }447 448  // IPv6 serializer449  if (host instanceof Array) {450    return "[" + serializeIPv6(host) + "]";451  }452 453  return host;454}455 456function domainToASCII(domain, beStrict = false) {457  const result = tr46.toASCII(domain, {458    checkBidi: true,459    checkHyphens: false,460    checkJoiners: true,461    useSTD3ASCIIRules: beStrict,462    verifyDNSLength: beStrict463  });464  if (result === null) {465    return failure;466  }467  return result;468}469 470function trimControlChars(url) {471  return url.replace(/^[\u0000-\u001F\u0020]+|[\u0000-\u001F\u0020]+$/g, "");472}473 474function trimTabAndNewline(url) {475  return url.replace(/\u0009|\u000A|\u000D/g, "");476}477 478function shortenPath(url) {479  const { path } = url;480  if (path.length === 0) {481    return;482  }483  if (url.scheme === "file" && path.length === 1 && isNormalizedWindowsDriveLetter(path[0])) {484    return;485  }486 487  path.pop();488}489 490function includesCredentials(url) {491  return url.username !== "" || url.password !== "";492}493 494function cannotHaveAUsernamePasswordPort(url) {495  return url.host === null || url.host === "" || url.cannotBeABaseURL || url.scheme === "file";496}497 498function isNormalizedWindowsDriveLetter(string) {499  return /^[A-Za-z]:$/.test(string);500}501 502function URLStateMachine(input, base, encodingOverride, url, stateOverride) {503  this.pointer = 0;504  this.input = input;505  this.base = base || null;506  this.encodingOverride = encodingOverride || "utf-8";507  this.stateOverride = stateOverride;508  this.url = url;509  this.failure = false;510  this.parseError = false;511 512  if (!this.url) {513    this.url = {514      scheme: "",515      username: "",516      password: "",517      host: null,518      port: null,519      path: [],520      query: null,521      fragment: null,522 523      cannotBeABaseURL: false524    };525 526    const res = trimControlChars(this.input);527    if (res !== this.input) {528      this.parseError = true;529    }530    this.input = res;531  }532 533  const res = trimTabAndNewline(this.input);534  if (res !== this.input) {535    this.parseError = true;536  }537  this.input = res;538 539  this.state = stateOverride || "scheme start";540 541  this.buffer = "";542  this.atFlag = false;543  this.arrFlag = false;544  this.passwordTokenSeenFlag = false;545 546  this.input = punycode.ucs2.decode(this.input);547 548  for (; this.pointer <= this.input.length; ++this.pointer) {549    const c = this.input[this.pointer];550    const cStr = isNaN(c) ? undefined : String.fromCodePoint(c);551 552    // exec state machine553    const ret = this["parse " + this.state](c, cStr);554    if (!ret) {555      break; // terminate algorithm556    } else if (ret === failure) {557      this.failure = true;558      break;559    }560  }561}562 563URLStateMachine.prototype["parse scheme start"] = function parseSchemeStart(c, cStr) {564  if (infra.isASCIIAlpha(c)) {565    this.buffer += cStr.toLowerCase();566    this.state = "scheme";567  } else if (!this.stateOverride) {568    this.state = "no scheme";569    --this.pointer;570  } else {571    this.parseError = true;572    return failure;573  }574 575  return true;576};577 578URLStateMachine.prototype["parse scheme"] = function parseScheme(c, cStr) {579  if (infra.isASCIIAlphanumeric(c) || c === 43 || c === 45 || c === 46) {580    this.buffer += cStr.toLowerCase();581  } else if (c === 58) {582    if (this.stateOverride) {583      if (isSpecial(this.url) && !isSpecialScheme(this.buffer)) {584        return false;585      }586 587      if (!isSpecial(this.url) && isSpecialScheme(this.buffer)) {588        return false;589      }590 591      if ((includesCredentials(this.url) || this.url.port !== null) && this.buffer === "file") {592        return false;593      }594 595      if (this.url.scheme === "file" && (this.url.host === "" || this.url.host === null)) {596        return false;597      }598    }599    this.url.scheme = this.buffer;600    if (this.stateOverride) {601      if (this.url.port === defaultPort(this.url.scheme)) {602        this.url.port = null;603      }604      return false;605    }606    this.buffer = "";607    if (this.url.scheme === "file") {608      if (this.input[this.pointer + 1] !== 47 || this.input[this.pointer + 2] !== 47) {609        this.parseError = true;610      }611      this.state = "file";612    } else if (isSpecial(this.url) && this.base !== null && this.base.scheme === this.url.scheme) {613      this.state = "special relative or authority";614    } else if (isSpecial(this.url)) {615      this.state = "special authority slashes";616    } else if (this.input[this.pointer + 1] === 47) {617      this.state = "path or authority";618      ++this.pointer;619    } else {620      this.url.cannotBeABaseURL = true;621      this.url.path.push("");622      this.state = "cannot-be-a-base-URL path";623    }624  } else if (!this.stateOverride) {625    this.buffer = "";626    this.state = "no scheme";627    this.pointer = -1;628  } else {629    this.parseError = true;630    return failure;631  }632 633  return true;634};635 636URLStateMachine.prototype["parse no scheme"] = function parseNoScheme(c) {637  if (this.base === null || (this.base.cannotBeABaseURL && c !== 35)) {638    return failure;639  } else if (this.base.cannotBeABaseURL && c === 35) {640    this.url.scheme = this.base.scheme;641    this.url.path = this.base.path.slice();642    this.url.query = this.base.query;643    this.url.fragment = "";644    this.url.cannotBeABaseURL = true;645    this.state = "fragment";646  } else if (this.base.scheme === "file") {647    this.state = "file";648    --this.pointer;649  } else {650    this.state = "relative";651    --this.pointer;652  }653 654  return true;655};656 657URLStateMachine.prototype["parse special relative or authority"] = function parseSpecialRelativeOrAuthority(c) {658  if (c === 47 && this.input[this.pointer + 1] === 47) {659    this.state = "special authority ignore slashes";660    ++this.pointer;661  } else {662    this.parseError = true;663    this.state = "relative";664    --this.pointer;665  }666 667  return true;668};669 670URLStateMachine.prototype["parse path or authority"] = function parsePathOrAuthority(c) {671  if (c === 47) {672    this.state = "authority";673  } else {674    this.state = "path";675    --this.pointer;676  }677 678  return true;679};680 681URLStateMachine.prototype["parse relative"] = function parseRelative(c) {682  this.url.scheme = this.base.scheme;683  if (isNaN(c)) {684    this.url.username = this.base.username;685    this.url.password = this.base.password;686    this.url.host = this.base.host;687    this.url.port = this.base.port;688    this.url.path = this.base.path.slice();689    this.url.query = this.base.query;690  } else if (c === 47) {691    this.state = "relative slash";692  } else if (c === 63) {693    this.url.username = this.base.username;694    this.url.password = this.base.password;695    this.url.host = this.base.host;696    this.url.port = this.base.port;697    this.url.path = this.base.path.slice();698    this.url.query = "";699    this.state = "query";700  } else if (c === 35) {701    this.url.username = this.base.username;702    this.url.password = this.base.password;703    this.url.host = this.base.host;704    this.url.port = this.base.port;705    this.url.path = this.base.path.slice();706    this.url.query = this.base.query;707    this.url.fragment = "";708    this.state = "fragment";709  } else if (isSpecial(this.url) && c === 92) {710    this.parseError = true;711    this.state = "relative slash";712  } else {713    this.url.username = this.base.username;714    this.url.password = this.base.password;715    this.url.host = this.base.host;716    this.url.port = this.base.port;717    this.url.path = this.base.path.slice(0, this.base.path.length - 1);718 719    this.state = "path";720    --this.pointer;721  }722 723  return true;724};725 726URLStateMachine.prototype["parse relative slash"] = function parseRelativeSlash(c) {727  if (isSpecial(this.url) && (c === 47 || c === 92)) {728    if (c === 92) {729      this.parseError = true;730    }731    this.state = "special authority ignore slashes";732  } else if (c === 47) {733    this.state = "authority";734  } else {735    this.url.username = this.base.username;736    this.url.password = this.base.password;737    this.url.host = this.base.host;738    this.url.port = this.base.port;739    this.state = "path";740    --this.pointer;741  }742 743  return true;744};745 746URLStateMachine.prototype["parse special authority slashes"] = function parseSpecialAuthoritySlashes(c) {747  if (c === 47 && this.input[this.pointer + 1] === 47) {748    this.state = "special authority ignore slashes";749    ++this.pointer;750  } else {751    this.parseError = true;752    this.state = "special authority ignore slashes";753    --this.pointer;754  }755 756  return true;757};758 759URLStateMachine.prototype["parse special authority ignore slashes"] = function parseSpecialAuthorityIgnoreSlashes(c) {760  if (c !== 47 && c !== 92) {761    this.state = "authority";762    --this.pointer;763  } else {764    this.parseError = true;765  }766 767  return true;768};769 770URLStateMachine.prototype["parse authority"] = function parseAuthority(c, cStr) {771  if (c === 64) {772    this.parseError = true;773    if (this.atFlag) {774      this.buffer = "%40" + this.buffer;775    }776    this.atFlag = true;777 778    // careful, this is based on buffer and has its own pointer (this.pointer != pointer) and inner chars779    const len = countSymbols(this.buffer);780    for (let pointer = 0; pointer < len; ++pointer) {781      const codePoint = this.buffer.codePointAt(pointer);782 783      if (codePoint === 58 && !this.passwordTokenSeenFlag) {784        this.passwordTokenSeenFlag = true;785        continue;786      }787      const encodedCodePoints = percentEncodeChar(codePoint, isUserinfoPercentEncode);788      if (this.passwordTokenSeenFlag) {789        this.url.password += encodedCodePoints;790      } else {791        this.url.username += encodedCodePoints;792      }793    }794    this.buffer = "";795  } else if (isNaN(c) || c === 47 || c === 63 || c === 35 ||796             (isSpecial(this.url) && c === 92)) {797    if (this.atFlag && this.buffer === "") {798      this.parseError = true;799      return failure;800    }801    this.pointer -= countSymbols(this.buffer) + 1;802    this.buffer = "";803    this.state = "host";804  } else {805    this.buffer += cStr;806  }807 808  return true;809};810 811URLStateMachine.prototype["parse hostname"] =812URLStateMachine.prototype["parse host"] = function parseHostName(c, cStr) {813  if (this.stateOverride && this.url.scheme === "file") {814    --this.pointer;815    this.state = "file host";816  } else if (c === 58 && !this.arrFlag) {817    if (this.buffer === "") {818      this.parseError = true;819      return failure;820    }821 822    const host = parseHost(this.buffer, isNotSpecial(this.url));823    if (host === failure) {824      return failure;825    }826 827    this.url.host = host;828    this.buffer = "";829    this.state = "port";830    if (this.stateOverride === "hostname") {831      return false;832    }833  } else if (isNaN(c) || c === 47 || c === 63 || c === 35 ||834             (isSpecial(this.url) && c === 92)) {835    --this.pointer;836    if (isSpecial(this.url) && this.buffer === "") {837      this.parseError = true;838      return failure;839    } else if (this.stateOverride && this.buffer === "" &&840               (includesCredentials(this.url) || this.url.port !== null)) {841      this.parseError = true;842      return false;843    }844 845    const host = parseHost(this.buffer, isNotSpecial(this.url));846    if (host === failure) {847      return failure;848    }849 850    this.url.host = host;851    this.buffer = "";852    this.state = "path start";853    if (this.stateOverride) {854      return false;855    }856  } else {857    if (c === 91) {858      this.arrFlag = true;859    } else if (c === 93) {860      this.arrFlag = false;861    }862    this.buffer += cStr;863  }864 865  return true;866};867 868URLStateMachine.prototype["parse port"] = function parsePort(c, cStr) {869  if (infra.isASCIIDigit(c)) {870    this.buffer += cStr;871  } else if (isNaN(c) || c === 47 || c === 63 || c === 35 ||872             (isSpecial(this.url) && c === 92) ||873             this.stateOverride) {874    if (this.buffer !== "") {875      const port = parseInt(this.buffer);876      if (port > Math.pow(2, 16) - 1) {877        this.parseError = true;878        return failure;879      }880      this.url.port = port === defaultPort(this.url.scheme) ? null : port;881      this.buffer = "";882    }883    if (this.stateOverride) {884      return false;885    }886    this.state = "path start";887    --this.pointer;888  } else {889    this.parseError = true;890    return failure;891  }892 893  return true;894};895 896const fileOtherwiseCodePoints = new Set([47, 92, 63, 35]);897 898function startsWithWindowsDriveLetter(input, pointer) {899  const length = input.length - pointer;900  return length >= 2 &&901    isWindowsDriveLetterCodePoints(input[pointer], input[pointer + 1]) &&902    (length === 2 || fileOtherwiseCodePoints.has(input[pointer + 2]));903}904 905URLStateMachine.prototype["parse file"] = function parseFile(c) {906  this.url.scheme = "file";907 908  if (c === 47 || c === 92) {909    if (c === 92) {910      this.parseError = true;911    }912    this.state = "file slash";913  } else if (this.base !== null && this.base.scheme === "file") {914    if (isNaN(c)) {915      this.url.host = this.base.host;916      this.url.path = this.base.path.slice();917      this.url.query = this.base.query;918    } else if (c === 63) {919      this.url.host = this.base.host;920      this.url.path = this.base.path.slice();921      this.url.query = "";922      this.state = "query";923    } else if (c === 35) {924      this.url.host = this.base.host;925      this.url.path = this.base.path.slice();926      this.url.query = this.base.query;927      this.url.fragment = "";928      this.state = "fragment";929    } else {930      if (!startsWithWindowsDriveLetter(this.input, this.pointer)) {931        this.url.host = this.base.host;932        this.url.path = this.base.path.slice();933        shortenPath(this.url);934      } else {935        this.parseError = true;936      }937 938      this.state = "path";939      --this.pointer;940    }941  } else {942    this.state = "path";943    --this.pointer;944  }945 946  return true;947};948 949URLStateMachine.prototype["parse file slash"] = function parseFileSlash(c) {950  if (c === 47 || c === 92) {951    if (c === 92) {952      this.parseError = true;953    }954    this.state = "file host";955  } else {956    if (this.base !== null && this.base.scheme === "file" &&957        !startsWithWindowsDriveLetter(this.input, this.pointer)) {958      if (isNormalizedWindowsDriveLetterString(this.base.path[0])) {959        this.url.path.push(this.base.path[0]);960      } else {961        this.url.host = this.base.host;962      }963    }964    this.state = "path";965    --this.pointer;966  }967 968  return true;969};970 971URLStateMachine.prototype["parse file host"] = function parseFileHost(c, cStr) {972  if (isNaN(c) || c === 47 || c === 92 || c === 63 || c === 35) {973    --this.pointer;974    if (!this.stateOverride && isWindowsDriveLetterString(this.buffer)) {975      this.parseError = true;976      this.state = "path";977    } else if (this.buffer === "") {978      this.url.host = "";979      if (this.stateOverride) {980        return false;981      }982      this.state = "path start";983    } else {984      let host = parseHost(this.buffer, isNotSpecial(this.url));985      if (host === failure) {986        return failure;987      }988      if (host === "localhost") {989        host = "";990      }991      this.url.host = host;992 993      if (this.stateOverride) {994        return false;995      }996 997      this.buffer = "";998      this.state = "path start";999    }1000  } else {1001    this.buffer += cStr;1002  }1003 1004  return true;1005};1006 1007URLStateMachine.prototype["parse path start"] = function parsePathStart(c) {1008  if (isSpecial(this.url)) {1009    if (c === 92) {1010      this.parseError = true;1011    }1012    this.state = "path";1013 1014    if (c !== 47 && c !== 92) {1015      --this.pointer;1016    }1017  } else if (!this.stateOverride && c === 63) {1018    this.url.query = "";1019    this.state = "query";1020  } else if (!this.stateOverride && c === 35) {1021    this.url.fragment = "";1022    this.state = "fragment";1023  } else if (c !== undefined) {1024    this.state = "path";1025    if (c !== 47) {1026      --this.pointer;1027    }1028  }1029 1030  return true;1031};1032 1033URLStateMachine.prototype["parse path"] = function parsePath(c) {1034  if (isNaN(c) || c === 47 || (isSpecial(this.url) && c === 92) ||1035      (!this.stateOverride && (c === 63 || c === 35))) {1036    if (isSpecial(this.url) && c === 92) {1037      this.parseError = true;1038    }1039 1040    if (isDoubleDot(this.buffer)) {1041      shortenPath(this.url);1042      if (c !== 47 && !(isSpecial(this.url) && c === 92)) {1043        this.url.path.push("");1044      }1045    } else if (isSingleDot(this.buffer) && c !== 47 &&1046               !(isSpecial(this.url) && c === 92)) {1047      this.url.path.push("");1048    } else if (!isSingleDot(this.buffer)) {1049      if (this.url.scheme === "file" && this.url.path.length === 0 && isWindowsDriveLetterString(this.buffer)) {1050        if (this.url.host !== "" && this.url.host !== null) {1051          this.parseError = true;1052          this.url.host = "";1053        }1054        this.buffer = this.buffer[0] + ":";1055      }1056      this.url.path.push(this.buffer);1057    }1058    this.buffer = "";1059    if (this.url.scheme === "file" && (c === undefined || c === 63 || c === 35)) {1060      while (this.url.path.length > 1 && this.url.path[0] === "") {1061        this.parseError = true;1062        this.url.path.shift();1063      }1064    }1065    if (c === 63) {1066      this.url.query = "";1067      this.state = "query";1068    }1069    if (c === 35) {1070      this.url.fragment = "";1071      this.state = "fragment";1072    }1073  } else {1074    // TODO: If c is not a URL code point and not "%", parse error.1075 1076    if (c === 37 &&1077      (!infra.isASCIIHex(this.input[this.pointer + 1]) ||1078        !infra.isASCIIHex(this.input[this.pointer + 2]))) {1079      this.parseError = true;1080    }1081 1082    this.buffer += percentEncodeChar(c, isPathPercentEncode);1083  }1084 1085  return true;1086};1087 1088URLStateMachine.prototype["parse cannot-be-a-base-URL path"] = function parseCannotBeABaseURLPath(c) {1089  if (c === 63) {1090    this.url.query = "";1091    this.state = "query";1092  } else if (c === 35) {1093    this.url.fragment = "";1094    this.state = "fragment";1095  } else {1096    // TODO: Add: not a URL code point1097    if (!isNaN(c) && c !== 37) {1098      this.parseError = true;1099    }1100 1101    if (c === 37 &&1102        (!infra.isASCIIHex(this.input[this.pointer + 1]) ||1103         !infra.isASCIIHex(this.input[this.pointer + 2]))) {1104      this.parseError = true;1105    }1106 1107    if (!isNaN(c)) {1108      this.url.path[0] = this.url.path[0] + percentEncodeChar(c, isC0ControlPercentEncode);1109    }1110  }1111 1112  return true;1113};1114 1115URLStateMachine.prototype["parse query"] = function parseQuery(c, cStr) {1116  if (isNaN(c) || (!this.stateOverride && c === 35)) {1117    if (!isSpecial(this.url) || this.url.scheme === "ws" || this.url.scheme === "wss") {1118      this.encodingOverride = "utf-8";1119    }1120 1121    const buffer = Buffer.from(this.buffer); // TODO: Use encoding override instead1122    for (let i = 0; i < buffer.length; ++i) {1123      if (buffer[i] < 0x21 ||1124          buffer[i] > 0x7E ||1125          buffer[i] === 0x22 || buffer[i] === 0x23 || buffer[i] === 0x3C || buffer[i] === 0x3E ||1126          (buffer[i] === 0x27 && isSpecial(this.url))) {1127        this.url.query += percentEncode(buffer[i]);1128      } else {1129        this.url.query += String.fromCodePoint(buffer[i]);1130      }1131    }1132 1133    this.buffer = "";1134    if (c === 35) {1135      this.url.fragment = "";1136      this.state = "fragment";1137    }1138  } else {1139    // TODO: If c is not a URL code point and not "%", parse error.1140    if (c === 37 &&1141      (!infra.isASCIIHex(this.input[this.pointer + 1]) ||1142        !infra.isASCIIHex(this.input[this.pointer + 2]))) {1143      this.parseError = true;1144    }1145 1146    this.buffer += cStr;1147  }1148 1149  return true;1150};1151 1152URLStateMachine.prototype["parse fragment"] = function parseFragment(c) {1153  if (isNaN(c)) { // do nothing1154  } else if (c === 0x0) {1155    this.parseError = true;1156  } else {1157    // TODO: If c is not a URL code point and not "%", parse error.1158    if (c === 37 &&1159      (!infra.isASCIIHex(this.input[this.pointer + 1]) ||1160        !infra.isASCIIHex(this.input[this.pointer + 2]))) {1161      this.parseError = true;1162    }1163 1164    this.url.fragment += percentEncodeChar(c, isFragmentPercentEncode);1165  }1166 1167  return true;1168};1169 1170function serializeURL(url, excludeFragment) {1171  let output = url.scheme + ":";1172  if (url.host !== null) {1173    output += "//";1174 1175    if (url.username !== "" || url.password !== "") {1176      output += url.username;1177      if (url.password !== "") {1178        output += ":" + url.password;1179      }1180      output += "@";1181    }1182 1183    output += serializeHost(url.host);1184 1185    if (url.port !== null) {1186      output += ":" + url.port;1187    }1188  } else if (url.host === null && url.scheme === "file") {1189    output += "//";1190  }1191 1192  if (url.cannotBeABaseURL) {1193    output += url.path[0];1194  } else {1195    for (const string of url.path) {1196      output += "/" + string;1197    }1198  }1199 1200  if (url.query !== null) {

Showing the first 1,200 of 1304 lines. Download the file for the rest.

Brunobkr/llama.cpp_AlgMor24_github · Team Ai