| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 20x 4x 4x 17x 17x 249x 249x 239x 10x 1x 1x 4x 24x 24x 24x 24x 24x 24x 24x 1089x 1089x 24x 19x 19x 5x 5x 5x 5x 19x 82x 63x 19x 17x 17x 17x 17x 17x 17x 17x 17x 17x 2x 2x 2x 2x 2x 80x 7x 4x 4x 3x 3x 4x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 17x 17x 17x 17x 17x 17x 17x 17x 17x 264x 264x 17x 17x 17x 17x 247x 247x 264x 264x 17x 17x 17x 17x 17x 247x 247x 247x 247x 247x 17x 17x 17x 2x 15x 291x 42x 42x 42x 4x 4x 38x 38x 38x 38x 42x 42x 42x 5x 5x 249x 249x 291x 86x 81x 86x 1023x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 24x 3x 24x 24x 24x 24x 1x 17x 17x 17x 17x 33x 17x 17x 1x 1x 1x | /* Copyright 2017 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ 'use strict'; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; Eif (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) { var globalScope = require('./global_scope'); var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || ''; var isAndroid = /Android/.test(userAgent); var isAndroidPre5 = /Android\s[0-4][^\d]/.test(userAgent); var isChrome = userAgent.indexOf('Chrom') >= 0; var isIOSChrome = userAgent.indexOf('CriOS') >= 0; var isIE = userAgent.indexOf('Trident') >= 0; var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent); var isSafari = /Safari\//.test(userAgent) && !/(Chrome\/|Android\s)/.test(userAgent); var hasDOM = (typeof window === 'undefined' ? 'undefined' : _typeof(window)) === 'object' && (typeof document === 'undefined' ? 'undefined' : _typeof(document)) === 'object'; Eif (typeof PDFJS === 'undefined') { globalScope.PDFJS = {}; } PDFJS.compatibilityChecked = true; (function normalizeURLObject() { Eif (!globalScope.URL) { globalScope.URL = globalScope.webkitURL; } })(); (function checkXMLHttpRequestResponseCompatibility() { Eif (typeof XMLHttpRequest === 'undefined') { return; } var xhrPrototype = XMLHttpRequest.prototype; var xhr = new XMLHttpRequest(); if (!('overrideMimeType' in xhr)) { Object.defineProperty(xhrPrototype, 'overrideMimeType', { value: function xmlHttpRequestOverrideMimeType(mimeType) {} }); } if ('responseType' in xhr) { return; } Object.defineProperty(xhrPrototype, 'responseType', { get: function xmlHttpRequestGetResponseType() { return this._responseType || 'text'; }, set: function xmlHttpRequestSetResponseType(value) { if (value === 'text' || value === 'arraybuffer') { this._responseType = value; if (value === 'arraybuffer' && typeof this.overrideMimeType === 'function') { this.overrideMimeType('text/plain; charset=x-user-defined'); } } } }); Object.defineProperty(xhrPrototype, 'response', { get: function xmlHttpRequestResponseGet() { if (this.responseType !== 'arraybuffer') { return this.responseText; } var text = this.responseText; var i, n = text.length; var result = new Uint8Array(n); for (i = 0; i < n; ++i) { result[i] = text.charCodeAt(i) & 0xFF; } return result.buffer; } }); })(); (function checkDatasetProperty() { Eif (!hasDOM) { return; } var div = document.createElement('div'); if ('dataset' in div) { return; } Object.defineProperty(HTMLElement.prototype, 'dataset', { get: function get() { if (this._dataset) { return this._dataset; } var dataset = {}; for (var j = 0, jj = this.attributes.length; j < jj; j++) { var attribute = this.attributes[j]; if (attribute.name.substring(0, 5) !== 'data-') { continue; } var key = attribute.name.substring(5).replace(/\-([a-z])/g, function (all, ch) { return ch.toUpperCase(); }); dataset[key] = attribute.value; } Object.defineProperty(this, '_dataset', { value: dataset, writable: false, enumerable: false }); return dataset; }, enumerable: true }); })(); (function checkOnBlobSupport() { Iif (isIE || isIOSChrome) { PDFJS.disableCreateObjectURL = true; } })(); (function checkNavigatorLanguage() { Eif (typeof navigator === 'undefined') { return; } if ('language' in navigator) { return; } PDFJS.locale = navigator.userLanguage || 'en-US'; })(); (function checkRangeRequests() { Iif (isSafari || isIOS) { PDFJS.disableRange = true; PDFJS.disableStream = true; } })(); (function checkSetPresenceInImageData() { Eif (!hasDOM) { return; } if (window.CanvasPixelArray) { if (typeof window.CanvasPixelArray.prototype.set !== 'function') { window.CanvasPixelArray.prototype.set = function (arr) { for (var i = 0, ii = this.length; i < ii; i++) { this[i] = arr[i]; } }; } } else { var polyfill = false, versionMatch; if (isChrome) { versionMatch = userAgent.match(/Chrom(e|ium)\/([0-9]+)\./); polyfill = versionMatch && parseInt(versionMatch[2]) < 21; } else if (isAndroid) { polyfill = isAndroidPre5; } else if (isSafari) { versionMatch = userAgent.match(/Version\/([0-9]+)\.([0-9]+)\.([0-9]+) Safari\//); polyfill = versionMatch && parseInt(versionMatch[1]) < 6; } if (polyfill) { var contextPrototype = window.CanvasRenderingContext2D.prototype; var createImageData = contextPrototype.createImageData; contextPrototype.createImageData = function (w, h) { var imageData = createImageData.call(this, w, h); imageData.data.set = function (arr) { for (var i = 0, ii = this.length; i < ii; i++) { this[i] = arr[i]; } }; return imageData; }; contextPrototype = null; } } })(); (function checkCanvasSizeLimitation() { Iif (isIOS || isAndroid) { PDFJS.maxCanvasPixels = 5242880; } })(); (function checkFullscreenSupport() { Eif (!hasDOM) { return; } if (isIE && window.parent !== window) { PDFJS.disableFullscreen = true; } })(); (function checkCurrentScript() { Eif (!hasDOM) { return; } if ('currentScript' in document) { return; } Object.defineProperty(document, 'currentScript', { get: function get() { var scripts = document.getElementsByTagName('script'); return scripts[scripts.length - 1]; }, enumerable: true, configurable: true }); })(); (function checkInputTypeNumberAssign() { Eif (!hasDOM) { return; } var el = document.createElement('input'); try { el.type = 'number'; } catch (ex) { var inputProto = el.constructor.prototype; var typeProperty = Object.getOwnPropertyDescriptor(inputProto, 'type'); Object.defineProperty(inputProto, 'type', { get: function get() { return typeProperty.get.call(this); }, set: function set(value) { typeProperty.set.call(this, value === 'number' ? 'text' : value); }, enumerable: true, configurable: true }); } })(); (function checkDocumentReadyState() { Eif (!hasDOM) { return; } if (!document.attachEvent) { return; } var documentProto = document.constructor.prototype; var readyStateProto = Object.getOwnPropertyDescriptor(documentProto, 'readyState'); Object.defineProperty(documentProto, 'readyState', { get: function get() { var value = readyStateProto.get.call(this); return value === 'interactive' ? 'loading' : value; }, set: function set(value) { readyStateProto.set.call(this, value); }, enumerable: true, configurable: true }); })(); (function checkChildNodeRemove() { Eif (!hasDOM) { return; } if (typeof Element.prototype.remove !== 'undefined') { return; } Element.prototype.remove = function () { if (this.parentNode) { this.parentNode.removeChild(this); } }; })(); (function checkObjectValues() { Eif (Object.values) { return; } Object.values = require('core-js/fn/object/values'); })(); (function checkArrayIncludes() { Eif (Array.prototype.includes) { return; } Array.prototype.includes = require('core-js/fn/array/includes'); })(); (function checkMathLog2() { Eif (Math.log2) { return; } Math.log2 = require('core-js/fn/math/log2'); })(); (function checkNumberIsNaN() { Eif (Number.isNaN) { return; } Number.isNaN = require('core-js/fn/number/is-nan'); })(); (function checkNumberIsInteger() { Eif (Number.isInteger) { return; } Number.isInteger = require('core-js/fn/number/is-integer'); })(); (function checkPromise() { Eif (globalScope.Promise) { return; } globalScope.Promise = require('core-js/fn/promise'); })(); (function checkWeakMap() { Eif (globalScope.WeakMap) { return; } globalScope.WeakMap = require('core-js/fn/weak-map'); })(); (function checkURLConstructor() { var hasWorkingUrl = false; try { Iif (typeof URL === 'function' && _typeof(URL.prototype) === 'object' && 'origin' in URL.prototype) { var u = new URL('b', 'http://a'); u.pathname = 'c%20d'; hasWorkingUrl = u.href === 'http://a/c%20d'; } } catch (e) {} Iif (hasWorkingUrl) { return; } var relative = Object.create(null); relative['ftp'] = 21; relative['file'] = 0; relative['gopher'] = 70; relative['http'] = 80; relative['https'] = 443; relative['ws'] = 80; relative['wss'] = 443; var relativePathDotMapping = Object.create(null); relativePathDotMapping['%2e'] = '.'; relativePathDotMapping['.%2e'] = '..'; relativePathDotMapping['%2e.'] = '..'; relativePathDotMapping['%2e%2e'] = '..'; function isRelativeScheme(scheme) { return relative[scheme] !== undefined; } function invalid() { clear.call(this); this._isInvalid = true; } function IDNAToASCII(h) { Iif (h === '') { invalid.call(this); } return h.toLowerCase(); } function percentEscape(c) { var unicode = c.charCodeAt(0); if (unicode > 0x20 && unicode < 0x7F && [0x22, 0x23, 0x3C, 0x3E, 0x3F, 0x60].indexOf(unicode) === -1) { return c; } return encodeURIComponent(c); } function percentEscapeQuery(c) { var unicode = c.charCodeAt(0); if (unicode > 0x20 && unicode < 0x7F && [0x22, 0x23, 0x3C, 0x3E, 0x60].indexOf(unicode) === -1) { return c; } return encodeURIComponent(c); } var EOF, ALPHA = /[a-zA-Z]/, ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/; function parse(input, stateOverride, base) { function err(message) { errors.push(message); } var state = stateOverride || 'scheme start', cursor = 0, buffer = '', seenAt = false, seenBracket = false, errors = []; loop: while ((input[cursor - 1] !== EOF || cursor === 0) && !this._isInvalid) { var c = input[cursor]; switch (state) { case 'scheme start': if (c && ALPHA.test(c)) { buffer += c.toLowerCase(); state = 'scheme'; } else Eif (!stateOverride) { buffer = ''; state = 'no scheme'; continue; } else { err('Invalid scheme.'); break loop; } break; case 'scheme': if (c && ALPHANUMERIC.test(c)) { buffer += c.toLowerCase(); } else if (c === ':') { this._scheme = buffer; buffer = ''; Iif (stateOverride) { break loop; } Eif (isRelativeScheme(this._scheme)) { this._isRelative = true; } Iif (this._scheme === 'file') { state = 'relative'; } else Iif (this._isRelative && base && base._scheme === this._scheme) { state = 'relative or authority'; } else Eif (this._isRelative) { state = 'authority first slash'; } else { state = 'scheme data'; } } else Eif (!stateOverride) { buffer = ''; cursor = 0; state = 'no scheme'; continue; } else if (c === EOF) { break loop; } else { err('Code point not allowed in scheme: ' + c); break loop; } break; case 'scheme data': if (c === '?') { this._query = '?'; state = 'query'; } else if (c === '#') { this._fragment = '#'; state = 'fragment'; } else { if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') { this._schemeData += percentEscape(c); } } break; case 'no scheme': if (!base || !isRelativeScheme(base._scheme)) { err('Missing scheme.'); invalid.call(this); } else { state = 'relative'; continue; } break; case 'relative or authority': if (c === '/' && input[cursor + 1] === '/') { state = 'authority ignore slashes'; } else { err('Expected /, got: ' + c); state = 'relative'; continue; } break; case 'relative': this._isRelative = true; Eif (this._scheme !== 'file') { this._scheme = base._scheme; } Iif (c === EOF) { this._host = base._host; this._port = base._port; this._path = base._path.slice(); this._query = base._query; this._username = base._username; this._password = base._password; break loop; } else Iif (c === '/' || c === '\\') { if (c === '\\') { err('\\ is an invalid code point.'); } state = 'relative slash'; } else Iif (c === '?') { this._host = base._host; this._port = base._port; this._path = base._path.slice(); this._query = '?'; this._username = base._username; this._password = base._password; state = 'query'; } else Iif (c === '#') { this._host = base._host; this._port = base._port; this._path = base._path.slice(); this._query = base._query; this._fragment = '#'; this._username = base._username; this._password = base._password; state = 'fragment'; } else { var nextC = input[cursor + 1]; var nextNextC = input[cursor + 2]; Eif (this._scheme !== 'file' || !ALPHA.test(c) || nextC !== ':' && nextC !== '|' || nextNextC !== EOF && nextNextC !== '/' && nextNextC !== '\\' && nextNextC !== '?' && nextNextC !== '#') { this._host = base._host; this._port = base._port; this._username = base._username; this._password = base._password; this._path = base._path.slice(); this._path.pop(); } state = 'relative path'; continue; } break; case 'relative slash': if (c === '/' || c === '\\') { if (c === '\\') { err('\\ is an invalid code point.'); } if (this._scheme === 'file') { state = 'file host'; } else { state = 'authority ignore slashes'; } } else { if (this._scheme !== 'file') { this._host = base._host; this._port = base._port; this._username = base._username; this._password = base._password; } state = 'relative path'; continue; } break; case 'authority first slash': Eif (c === '/') { state = 'authority second slash'; } else { err('Expected \'/\', got: ' + c); state = 'authority ignore slashes'; continue; } break; case 'authority second slash': state = 'authority ignore slashes'; Iif (c !== '/') { err('Expected \'/\', got: ' + c); continue; } break; case 'authority ignore slashes': Eif (c !== '/' && c !== '\\') { state = 'authority'; continue; } else { err('Expected authority, got: ' + c); } break; case 'authority': Iif (c === '@') { if (seenAt) { err('@ already seen.'); buffer += '%40'; } seenAt = true; for (var i = 0; i < buffer.length; i++) { var cp = buffer[i]; if (cp === '\t' || cp === '\n' || cp === '\r') { err('Invalid whitespace in authority.'); continue; } if (cp === ':' && this._password === null) { this._password = ''; continue; } var tempC = percentEscape(cp); if (this._password !== null) { this._password += tempC; } else { this._username += tempC; } } buffer = ''; } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') { cursor -= buffer.length; buffer = ''; state = 'host'; continue; } else { buffer += c; } break; case 'file host': if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') { if (buffer.length === 2 && ALPHA.test(buffer[0]) && (buffer[1] === ':' || buffer[1] === '|')) { state = 'relative path'; } else if (buffer.length === 0) { state = 'relative path start'; } else { this._host = IDNAToASCII.call(this, buffer); buffer = ''; state = 'relative path start'; } continue; } else if (c === '\t' || c === '\n' || c === '\r') { err('Invalid whitespace in file host.'); } else { buffer += c; } break; case 'host': case 'hostname': Iif (c === ':' && !seenBracket) { this._host = IDNAToASCII.call(this, buffer); buffer = ''; state = 'port'; if (stateOverride === 'hostname') { break loop; } } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') { this._host = IDNAToASCII.call(this, buffer); buffer = ''; state = 'relative path start'; Iif (stateOverride) { break loop; } continue; } else Eif (c !== '\t' && c !== '\n' && c !== '\r') { Iif (c === '[') { seenBracket = true; } else Iif (c === ']') { seenBracket = false; } buffer += c; } else { err('Invalid code point in host/hostname: ' + c); } break; case 'port': if (/[0-9]/.test(c)) { buffer += c; } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#' || stateOverride) { if (buffer !== '') { var temp = parseInt(buffer, 10); if (temp !== relative[this._scheme]) { this._port = temp + ''; } buffer = ''; } if (stateOverride) { break loop; } state = 'relative path start'; continue; } else if (c === '\t' || c === '\n' || c === '\r') { err('Invalid code point in port: ' + c); } else { invalid.call(this); } break; case 'relative path start': Iif (c === '\\') { err('\'\\\' not allowed in path.'); } state = 'relative path'; if (c !== '/' && c !== '\\') { continue; } break; case 'relative path': if (c === EOF || c === '/' || c === '\\' || !stateOverride && (c === '?' || c === '#')) { Iif (c === '\\') { err('\\ not allowed in relative path.'); } var tmp; Iif (tmp = relativePathDotMapping[buffer.toLowerCase()]) { buffer = tmp; } if (buffer === '..') { this._path.pop(); Iif (c !== '/' && c !== '\\') { this._path.push(''); } } else Iif (buffer === '.' && c !== '/' && c !== '\\') { this._path.push(''); } else Eif (buffer !== '.') { Iif (this._scheme === 'file' && this._path.length === 0 && buffer.length === 2 && ALPHA.test(buffer[0]) && buffer[1] === '|') { buffer = buffer[0] + ':'; } this._path.push(buffer); } buffer = ''; Iif (c === '?') { this._query = '?'; state = 'query'; } else if (c === '#') { this._fragment = '#'; state = 'fragment'; } } else Eif (c !== '\t' && c !== '\n' && c !== '\r') { buffer += percentEscape(c); } break; case 'query': if (!stateOverride && c === '#') { this._fragment = '#'; state = 'fragment'; } else if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') { this._query += percentEscapeQuery(c); } break; case 'fragment': if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') { this._fragment += c; } break; } cursor++; } } function clear() { this._scheme = ''; this._schemeData = ''; this._username = ''; this._password = null; this._host = ''; this._port = ''; this._path = []; this._query = ''; this._fragment = ''; this._isInvalid = false; this._isRelative = false; } function JURL(url, base) { if (base !== undefined && !(base instanceof JURL)) { base = new JURL(String(base)); } this._url = url; clear.call(this); var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, ''); parse.call(this, input, null, base); } JURL.prototype = { toString: function toString() { return this.href; }, get href() { Iif (this._isInvalid) { return this._url; } var authority = ''; Iif (this._username !== '' || this._password !== null) { authority = this._username + (this._password !== null ? ':' + this._password : '') + '@'; } return this.protocol + (this._isRelative ? '//' + authority + this.host : '') + this.pathname + this._query + this._fragment; }, set href(value) { clear.call(this); parse.call(this, value); }, get protocol() { return this._scheme + ':'; }, set protocol(value) { if (this._isInvalid) { return; } parse.call(this, value + ':', 'scheme start'); }, get host() { return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host; }, set host(value) { if (this._isInvalid || !this._isRelative) { return; } parse.call(this, value, 'host'); }, get hostname() { return this._host; }, set hostname(value) { if (this._isInvalid || !this._isRelative) { return; } parse.call(this, value, 'hostname'); }, get port() { return this._port; }, set port(value) { if (this._isInvalid || !this._isRelative) { return; } parse.call(this, value, 'port'); }, get pathname() { return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData; }, set pathname(value) { if (this._isInvalid || !this._isRelative) { return; } this._path = []; parse.call(this, value, 'relative path start'); }, get search() { return this._isInvalid || !this._query || this._query === '?' ? '' : this._query; }, set search(value) { if (this._isInvalid || !this._isRelative) { return; } this._query = '?'; if (value[0] === '?') { value = value.slice(1); } parse.call(this, value, 'query'); }, get hash() { return this._isInvalid || !this._fragment || this._fragment === '#' ? '' : this._fragment; }, set hash(value) { if (this._isInvalid) { return; } this._fragment = '#'; if (value[0] === '#') { value = value.slice(1); } parse.call(this, value, 'fragment'); }, get origin() { var host; if (this._isInvalid || !this._scheme) { return ''; } switch (this._scheme) { case 'data': case 'file': case 'javascript': case 'mailto': return 'null'; case 'blob': try { return new JURL(this._schemeData).origin || 'null'; } catch (_) {} return 'null'; } host = this.host; if (!host) { return ''; } return this._scheme + '://' + host; } }; var OriginalURL = globalScope.URL; Iif (OriginalURL) { JURL.createObjectURL = function (blob) { return OriginalURL.createObjectURL.apply(OriginalURL, arguments); }; JURL.revokeObjectURL = function (url) { OriginalURL.revokeObjectURL(url); }; } globalScope.URL = JURL; })(); } |