{ "version": 3, "sources": [ "node_modules/browserify/node_modules/browser-pack/_prelude.js", "lib/browser/fileReader.js", "lib/browser/fingerprint.js", "lib/browser/httpStack.js", "lib/browser/index.js", "lib/browser/isCordova.js", "lib/browser/isReactNative.js", "lib/browser/readAsByteArray.js", "lib/browser/uriToBlob.js", "lib/browser/urlStorage.js", "lib/error.js", "lib/logger.js", "lib/noopUrlStorage.js", "lib/upload.js", "lib/uuid.js", "node_modules/js-base64/base64.js", "node_modules/querystringify/index.js", "node_modules/requires-port/index.js", "node_modules/url-parse/index.js" ], "names": [], "mappings": "AAAA;;;;;;;;ACAA;;AACA;;AACA;;AACA;;;;;;;;;;IAEM,U;AACJ;AACA,sBAAa,IAAb,EAAmB;AAAA;;AACjB,SAAK,KAAL,GAAa,IAAb;AACA,SAAK,IAAL,GAAY,IAAI,CAAC,IAAjB;AACD;;;;0BAEM,K,EAAO,G,EAAK;AACjB;AACA;AACA;AACA,UAAI,4BAAJ,EAAiB;AACf,eAAO,iCAAgB,KAAK,KAAL,CAAW,KAAX,CAAiB,KAAjB,EAAwB,GAAxB,CAAhB,CAAP;AACD;;AAED,UAAM,KAAK,GAAG,KAAK,KAAL,CAAW,KAAX,CAAiB,KAAjB,EAAwB,GAAxB,CAAd;;AACA,aAAO,OAAO,CAAC,OAAR,CAAgB;AAAE,QAAA,KAAK,EAAL;AAAF,OAAhB,CAAP;AACD;;;4BAEQ,CACP;AACD;;;;;;IAGG,Y;AACJ,wBAAa,MAAb,EAAqB,SAArB,EAAgC;AAAA;;AAC9B,SAAK,UAAL,GAAkB,SAAlB;AACA,SAAK,OAAL,GAAe,SAAf;AACA,SAAK,aAAL,GAAqB,CAArB;AACA,SAAK,OAAL,GAAe,MAAf;AACA,SAAK,KAAL,GAAa,KAAb;AACD;;;;0BAEM,K,EAAO,G,EAAK;AACjB,UAAI,KAAK,GAAG,KAAK,aAAjB,EAAgC;AAC9B,eAAO,OAAO,CAAC,MAAR,CAAe,IAAI,KAAJ,CAAU,sDAA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EAAkB;AAChB,IAAA,KAAK,CAAC,OAAN,CAAc,UAAC,IAAD,EAAO,KAAP,EAAiB;AAC7B,MAAA,IAAI,CAAC,SAAL,GAAiB,YAAY,CAAC,KAAD,CAAZ,IAAuB,IAAxC;AACD,KAFD;AAGD;;AAED,SAAO,KAAP;AACD;;AAED,UAAU,CAAC,cAAX,GAA4B,cAA5B;eAEe,U;;;;;;;;;;;AC1+Bf;;;;;;;;;;;;AAYe,SAAS,IAAT,GAAiB;AAC9B,SAAO,uCAAuC,OAAvC,CAA+C,OAA/C,EAAwD,UAAC,CAAD,EAAO;AACpE,QAAI,CAAC,GAAG,IAAI,CAAC,MAAL,KAAgB,EAAhB,GAAqB,CAA7B;AAAA,QACE,CAAC,GAAG,CAAC,IAAI,GAAL,GAAW,CAAX,GAAgB,CAAC,GAAG,GAAJ,GAAU,GADhC;AAEA,WAAO,CAAC,CAAC,QAAF,CAAW,EAAX,CAAP;AACD,GAJM,CAAP;AAKD;;;;AClBD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;ACxNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC3EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA", "file": "generated.js", "sourceRoot": "", "sourcesContent": [ "(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o {\n if (done) {\n this._done = true\n } else if (this._buffer === undefined) {\n this._buffer = value\n } else {\n this._buffer = concat(this._buffer, value)\n }\n\n return this._readUntilEnoughDataOrDone(start, end)\n })\n }\n\n _getDataFromBuffer (start, end) {\n // Remove data from buffer before `start`.\n // Data might be reread from the buffer if an upload fails, so we can only\n // safely delete data when it comes *before* what is currently being read.\n if (start > this._bufferOffset) {\n this._buffer = this._buffer.slice(start - this._bufferOffset)\n this._bufferOffset = start\n }\n // If the buffer is empty after removing old data, all data has been read.\n const hasAllDataBeenRead = len(this._buffer) === 0\n if (this._done && hasAllDataBeenRead) {\n return null\n }\n // We already removed data before `start`, so we just return the first\n // chunk from the buffer.\n return this._buffer.slice(0, end - start)\n }\n\n close () {\n if (this._reader.cancel) {\n this._reader.cancel()\n }\n }\n}\n\nfunction len (blobOrArray) {\n if (blobOrArray === undefined) return 0\n if (blobOrArray.size !== undefined) return blobOrArray.size\n return blobOrArray.length\n}\n\n/*\n Typed arrays and blobs don't have a concat method.\n This function helps StreamSource accumulate data to reach chunkSize.\n*/\nfunction concat (a, b) {\n if (a.concat) { // Is `a` an Array?\n return a.concat(b)\n }\n if (a instanceof Blob) {\n return new Blob([a, b], { type: a.type })\n }\n if (a.set) { // Is `a` a typed array?\n var c = new a.constructor(a.length + b.length)\n c.set(a)\n c.set(b, a.length)\n return c\n }\n throw new Error('Unknown data type')\n}\n\nexport default class FileReader {\n openFile (input, chunkSize) {\n // In React Native, when user selects a file, instead of a File or Blob,\n // you usually get a file object {} with a uri property that contains\n // a local path to the file. We use XMLHttpRequest to fetch\n // the file blob, before uploading with tus.\n if (isReactNative() && input && typeof input.uri !== 'undefined') {\n return uriToBlob(input.uri)\n .then((blob) => new FileSource(blob))\n .catch((err) => {\n throw new Error(`tus: cannot fetch \\`file.uri\\` as Blob, make sure the uri is correct and accessible. ${err}`)\n })\n }\n\n // Since we emulate the Blob type in our tests (not all target browsers\n // support it), we cannot use `instanceof` for testing whether the input value\n // can be handled. Instead, we simply check is the slice() function and the\n // size property are available.\n if (typeof input.slice === 'function' && typeof input.size !== 'undefined') {\n return Promise.resolve(new FileSource(input))\n }\n\n if (typeof input.read === 'function') {\n chunkSize = +chunkSize\n if (!isFinite(chunkSize)) {\n return Promise.reject(new Error('cannot create source for stream without a finite value for the `chunkSize` option'))\n }\n\n return Promise.resolve(new StreamSource(input, chunkSize))\n }\n\n return Promise.reject(new Error('source object may only be an instance of File, Blob, or Reader in this environment'))\n }\n}\n", "import isReactNative from './isReactNative'\n\n// TODO: Differenciate between input types\n\n/**\n * Generate a fingerprint for a file which will be used the store the endpoint\n *\n * @param {File} file\n * @param {Object} options\n * @param {Function} callback\n */\nexport default function fingerprint (file, options) {\n if (isReactNative()) {\n return Promise.resolve(reactNativeFingerprint(file, options))\n }\n\n return Promise.resolve([\n 'tus-br',\n file.name,\n file.type,\n file.size,\n file.lastModified,\n options.endpoint,\n ].join('-'))\n}\n\nfunction reactNativeFingerprint (file, options) {\n const exifHash = file.exif ? hashCode(JSON.stringify(file.exif)) : 'noexif'\n return [\n 'tus-rn',\n file.name || 'noname',\n file.size || 'nosize',\n exifHash,\n options.endpoint,\n ].join('/')\n}\n\nfunction hashCode (str) {\n // from https://stackoverflow.com/a/8831937/151666\n var hash = 0\n if (str.length === 0) {\n return hash\n }\n for (var i = 0; i < str.length; i++) {\n var char = str.charCodeAt(i)\n hash = ((hash << 5) - hash) + char\n hash &= hash // Convert to 32bit integer\n }\n return hash\n}\n", "/* global window */\n\nexport default class XHRHttpStack {\n createRequest (method, url) {\n return new Request(method, url)\n }\n\n getName () {\n return 'XHRHttpStack'\n }\n}\n\nclass Request {\n constructor (method, url) {\n this._xhr = new XMLHttpRequest()\n this._xhr.open(method, url, true)\n\n this._method = method\n this._url = url\n this._headers = {}\n }\n\n getMethod () {\n return this._method\n }\n\n getURL () {\n return this._url\n }\n\n setHeader (header, value) {\n this._xhr.setRequestHeader(header, value)\n this._headers[header] = value\n }\n\n getHeader (header) {\n return this._headers[header]\n }\n\n setProgressHandler (progressHandler) {\n // Test support for progress events before attaching an event listener\n if (!('upload' in this._xhr)) {\n return\n }\n\n this._xhr.upload.onprogress = (e) => {\n if (!e.lengthComputable) {\n return\n }\n\n progressHandler(e.loaded)\n }\n }\n\n send (body = null) {\n return new Promise((resolve, reject) => {\n this._xhr.onload = () => {\n resolve(new Response(this._xhr))\n }\n\n this._xhr.onerror = (err) => {\n reject(err)\n }\n\n this._xhr.send(body)\n })\n }\n\n abort () {\n this._xhr.abort()\n return Promise.resolve()\n }\n\n getUnderlyingObject () {\n return this._xhr\n }\n}\n\nclass Response {\n constructor (xhr) {\n this._xhr = xhr\n }\n\n getStatus () {\n return this._xhr.status\n }\n\n getHeader (header) {\n return this._xhr.getResponseHeader(header)\n }\n\n getBody () {\n return this._xhr.responseText\n }\n\n getUnderlyingObject () {\n return this._xhr\n }\n}\n", "/* global window */\nimport BaseUpload from '../upload'\nimport NoopUrlStorage from '../noopUrlStorage'\nimport { enableDebugLog } from '../logger'\n\nimport { canStoreURLs, WebStorageUrlStorage } from './urlStorage'\nimport HttpStack from './httpStack'\nimport FileReader from './fileReader'\nimport fingerprint from './fingerprint'\n\nconst defaultOptions = {\n ...BaseUpload.defaultOptions,\n httpStack : new HttpStack(),\n fileReader: new FileReader(),\n urlStorage: (canStoreURLs ? new WebStorageUrlStorage() : new NoopUrlStorage()),\n fingerprint,\n}\n\nclass Upload extends BaseUpload {\n constructor (file = null, options = {}) {\n options = { ...defaultOptions, ...options }\n super(file, options)\n }\n\n static terminate (url, options, cb) {\n options = { ...defaultOptions, ...options }\n return BaseUpload.terminate(url, options, cb)\n }\n}\n\nconst { XMLHttpRequest, Blob } = window\n\nconst isSupported = (\n XMLHttpRequest\n && Blob\n && typeof Blob.prototype.slice === 'function'\n)\n\nexport {\n Upload,\n canStoreURLs,\n defaultOptions,\n isSupported,\n enableDebugLog,\n HttpStack\n}\n", "const isCordova = () => typeof window != 'undefined' && (\n typeof window.PhoneGap != 'undefined'\n || typeof window.Cordova != 'undefined'\n || typeof window.cordova != 'undefined')\n\nexport default isCordova\n", "const isReactNative = () => (typeof navigator !== 'undefined'\n && typeof navigator.product === 'string'\n && navigator.product.toLowerCase() === 'reactnative')\n\nexport default isReactNative\n", "/**\n * readAsByteArray converts a File object to a Uint8Array.\n * This function is only used on the Apache Cordova platform.\n * See https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/index.html#read-a-file\n */\nexport default function readAsByteArray (chunk) {\n return new Promise((resolve, reject) => {\n const reader = new FileReader()\n reader.onload = () => {\n const value = new Uint8Array(reader.result)\n resolve({ value })\n }\n reader.onerror = (err) => {\n reject(err)\n }\n reader.readAsArrayBuffer(chunk)\n })\n}\n", "/**\n * uriToBlob resolves a URI to a Blob object. This is used for\n * React Native to retrieve a file (identified by a file://\n * URI) as a blob.\n */\nexport default function uriToBlob (uri) {\n return new Promise((resolve, reject) => {\n const xhr = new XMLHttpRequest()\n xhr.responseType = 'blob'\n xhr.onload = () => {\n const blob = xhr.response\n resolve(blob)\n }\n xhr.onerror = (err) => {\n reject(err)\n }\n xhr.open('GET', uri)\n xhr.send()\n })\n}\n", "/* global window, localStorage */\n\nlet hasStorage = false\ntry {\n hasStorage = 'localStorage' in window\n\n // Attempt to store and read entries from the local storage to detect Private\n // Mode on Safari on iOS (see #49)\n var key = 'tusSupport'\n localStorage.setItem(key, localStorage.getItem(key))\n} catch (e) {\n // If we try to access localStorage inside a sandboxed iframe, a SecurityError\n // is thrown. When in private mode on iOS Safari, a QuotaExceededError is\n // thrown (see #49)\n if (e.code === e.SECURITY_ERR || e.code === e.QUOTA_EXCEEDED_ERR) {\n hasStorage = false\n } else {\n throw e\n }\n}\n\nexport const canStoreURLs = hasStorage\n\nexport class WebStorageUrlStorage {\n findAllUploads () {\n const results = this._findEntries('tus::')\n return Promise.resolve(results)\n }\n\n findUploadsByFingerprint (fingerprint) {\n const results = this._findEntries(`tus::${fingerprint}::`)\n return Promise.resolve(results)\n }\n\n removeUpload (urlStorageKey) {\n localStorage.removeItem(urlStorageKey)\n return Promise.resolve()\n }\n\n addUpload (fingerprint, upload) {\n const id = Math.round(Math.random() * 1e12)\n const key = `tus::${fingerprint}::${id}`\n\n localStorage.setItem(key, JSON.stringify(upload))\n return Promise.resolve(key)\n }\n\n _findEntries (prefix) {\n const results = []\n\n for (let i = 0; i < localStorage.length; i++) {\n const key = localStorage.key(i)\n if (key.indexOf(prefix) !== 0) continue\n\n try {\n const upload = JSON.parse(localStorage.getItem(key))\n upload.urlStorageKey = key\n\n results.push(upload)\n } catch (e) {\n // The JSON parse error is intentionally ignored here, so a malformed\n // entry in the storage cannot prevent an upload.\n }\n }\n\n return results\n }\n}\n", "class DetailedError extends Error {\n constructor (message, causingErr = null, req = null, res = null) {\n super(message)\n\n this.originalRequest = req\n this.originalResponse = res\n this.causingError = causingErr\n\n if (causingErr != null) {\n message += `, caused by ${causingErr.toString()}`\n }\n\n if (req != null) {\n const requestId = req.getHeader('X-Request-ID') || 'n/a'\n const method = req.getMethod()\n const url = req.getURL()\n const status = res ? res.getStatus() : 'n/a'\n const body = res ? (res.getBody() || '') : 'n/a'\n message += `, originated from request (method: ${method}, url: ${url}, response code: ${status}, response text: ${body}, request id: ${requestId})`\n }\n this.message = message\n }\n}\n\nexport default DetailedError\n", "/* eslint no-console: \"off\" */\n\nlet isEnabled = false\n\nexport function enableDebugLog () {\n isEnabled = true\n}\n\nexport function log (msg) {\n if (!isEnabled) return\n console.log(msg)\n}\n", "/* eslint no-unused-vars: \"off\" */\n\nexport default class NoopUrlStorage {\n listAllUploads () {\n return Promise.resolve([])\n }\n\n findUploadsByFingerprint (fingerprint) {\n return Promise.resolve([])\n }\n\n removeUpload (urlStorageKey) {\n return Promise.resolve()\n }\n\n addUpload (fingerprint, upload) {\n return Promise.resolve(null)\n }\n}\n", "/* global window */\nimport { Base64 } from 'js-base64'\nimport URL from 'url-parse'\nimport DetailedError from './error'\nimport { log } from './logger'\nimport uuid from './uuid'\n\nconst defaultOptions = {\n endpoint: null,\n\n uploadUrl : null,\n metadata : {},\n fingerprint: null,\n uploadSize : null,\n\n onProgress : null,\n onChunkComplete : null,\n onSuccess : null,\n onError : null,\n _onUploadUrlAvailable: null,\n\n overridePatchMethod: false,\n headers : {},\n addRequestId : false,\n onBeforeRequest : null,\n onAfterResponse : null,\n onShouldRetry : null,\n\n chunkSize : Infinity,\n retryDelays : [0, 1000, 3000, 5000],\n parallelUploads : 1,\n storeFingerprintForResuming: true,\n removeFingerprintOnSuccess : false,\n uploadLengthDeferred : false,\n uploadDataDuringCreation : false,\n\n urlStorage: null,\n fileReader: null,\n httpStack : null,\n}\n\nclass BaseUpload {\n constructor (file, options) {\n // Warn about removed options from previous versions\n if ('resume' in options) {\n console.log('tus: The `resume` option has been removed in tus-js-client v2. Please use the URL storage API instead.') // eslint-disable-line no-console\n }\n\n // The default options will already be added from the wrapper classes.\n this.options = options\n\n // The storage module used to store URLs\n this._urlStorage = this.options.urlStorage\n\n // The underlying File/Blob object\n this.file = file\n\n // The URL against which the file will be uploaded\n this.url = null\n\n // The underlying request object for the current PATCH request\n this._req = null\n\n // The fingerpinrt for the current file (set after start())\n this._fingerprint = null\n\n // The key that the URL storage returned when saving an URL with a fingerprint,\n this._urlStorageKey = null\n\n // The offset used in the current PATCH request\n this._offset = null\n\n // True if the current PATCH request has been aborted\n this._aborted = false\n\n // The file's size in bytes\n this._size = null\n\n // The Source object which will wrap around the given file and provides us\n // with a unified interface for getting its size and slice chunks from its\n // content allowing us to easily handle Files, Blobs, Buffers and Streams.\n this._source = null\n\n // The current count of attempts which have been made. Zero indicates none.\n this._retryAttempt = 0\n\n // The timeout's ID which is used to delay the next retry\n this._retryTimeout = null\n\n // The offset of the remote upload before the latest attempt was started.\n this._offsetBeforeRetry = 0\n\n // An array of BaseUpload instances which are used for uploading the different\n // parts, if the parallelUploads option is used.\n this._parallelUploads = null\n\n // An array of upload URLs which are used for uploading the different\n // parts, if the parallelUploads option is used.\n this._parallelUploadUrls = null\n }\n\n /**\n * Use the Termination extension to delete an upload from the server by sending a DELETE\n * request to the specified upload URL. This is only possible if the server supports the\n * Termination extension. If the `options.retryDelays` property is set, the method will\n * also retry if an error ocurrs.\n *\n * @param {String} url The upload's URL which will be terminated.\n * @param {object} options Optional options for influencing HTTP requests.\n * @return {Promise} The Promise will be resolved/rejected when the requests finish.\n */\n static terminate (url, options) {\n // Count the number of arguments to see if a callback is being provided as the last\n // argument in the old style required by tus-js-client 1.x, then throw an error if it is.\n // `arguments` is a JavaScript built-in variable that contains all of the function's arguments.\n if (arguments.length > 1 && typeof arguments[arguments.length - 1] === 'function') {\n throw new Error('tus: the terminate function does not accept a callback since v2 anymore; please use the returned Promise instead')\n }\n // Note that in order for the trick above to work, a default value cannot be set for `options`,\n // so the check below replaces the old default `{}`.\n if (options === undefined) {\n options = {}\n }\n\n const req = openRequest('DELETE', url, options)\n\n return sendRequest(req, null, options).then((res) => {\n // A 204 response indicates a successfull request\n if (res.getStatus() === 204) {\n return\n }\n\n throw new DetailedError('tus: unexpected response while terminating upload', null, req, res)\n }).catch((err) => {\n if (!(err instanceof DetailedError)) {\n err = new DetailedError('tus: failed to terminate upload', err, req, null)\n }\n\n if (!shouldRetry(err, 0, options)) {\n throw err\n }\n\n // Instead of keeping track of the retry attempts, we remove the first element from the delays\n // array. If the array is empty, all retry attempts are used up and we will bubble up the error.\n // We recursively call the terminate function will removing elements from the retryDelays array.\n const delay = options.retryDelays[0]\n const remainingDelays = options.retryDelays.slice(1)\n const newOptions = {\n ...options,\n retryDelays: remainingDelays,\n }\n return new Promise((resolve) => setTimeout(resolve, delay))\n .then(() => BaseUpload.terminate(url, newOptions))\n })\n }\n\n findPreviousUploads () {\n return this.options.fingerprint(this.file, this.options)\n .then((fingerprint) => this._urlStorage.findUploadsByFingerprint(fingerprint))\n }\n\n resumeFromPreviousUpload (previousUpload) {\n this.url = previousUpload.uploadUrl || null\n this._parallelUploadUrls = previousUpload.parallelUploadUrls || null\n this._urlStorageKey = previousUpload.urlStorageKey\n }\n\n start () {\n const file = this.file\n\n if (!file) {\n this._emitError(new Error('tus: no file or stream to upload provided'))\n return\n }\n\n if (!this.options.endpoint && !this.options.uploadUrl) {\n this._emitError(new Error('tus: neither an endpoint or an upload URL is provided'))\n return\n }\n\n const retryDelays = this.options.retryDelays\n if (retryDelays != null && Object.prototype.toString.call(retryDelays) !== '[object Array]') {\n this._emitError(new Error('tus: the `retryDelays` option must either be an array or null'))\n return\n }\n\n if (this.options.parallelUploads > 1) {\n // Test which options are incompatible with parallel uploads.\n ['uploadUrl', 'uploadSize', 'uploadLengthDeferred'].forEach((optionName) => {\n if (this.options[optionName]) {\n this._emitError(new Error(`tus: cannot use the ${optionName} option when parallelUploads is enabled`))\n }\n })\n }\n\n this.options.fingerprint(file, this.options)\n .then((fingerprint) => {\n if (fingerprint == null) {\n log('No fingerprint was calculated meaning that the upload cannot be stored in the URL storage.')\n } else {\n log(`Calculated fingerprint: ${fingerprint}`)\n }\n\n this._fingerprint = fingerprint\n\n if (this._source) {\n return this._source\n }\n return this.options.fileReader.openFile(file, this.options.chunkSize)\n })\n .then((source) => {\n this._source = source\n\n // If the upload was configured to use multiple requests or if we resume from\n // an upload which used multiple requests, we start a parallel upload.\n if (this.options.parallelUploads > 1 || this._parallelUploadUrls != null) {\n this._startParallelUpload()\n } else {\n this._startSingleUpload()\n }\n })\n .catch((err) => {\n this._emitError(err)\n })\n }\n\n /**\n * Initiate the uploading procedure for a parallelized upload, where one file is split into\n * multiple request which are run in parallel.\n *\n * @api private\n */\n _startParallelUpload () {\n const totalSize = this._size = this._source.size\n let totalProgress = 0\n this._parallelUploads = []\n\n const partCount = this._parallelUploadUrls != null ? this._parallelUploadUrls.length : this.options.parallelUploads\n\n // The input file will be split into multiple slices which are uploaded in separate\n // requests. Here we generate the start and end position for the slices.\n const parts = splitSizeIntoParts(this._source.size, partCount, this._parallelUploadUrls)\n\n // Create an empty list for storing the upload URLs\n this._parallelUploadUrls = new Array(parts.length)\n\n // Generate a promise for each slice that will be resolve if the respective\n // upload is completed.\n const uploads = parts.map((part, index) => {\n let lastPartProgress = 0\n\n return this._source.slice(part.start, part.end)\n .then(({ value }) => new Promise((resolve, reject) => {\n // Merge with the user supplied options but overwrite some values.\n const options = {\n ...this.options,\n // If available, the partial upload should be resumed from a previous URL.\n uploadUrl : part.uploadUrl || null,\n // We take manually care of resuming for partial uploads, so they should\n // not be stored in the URL storage.\n storeFingerprintForResuming: false,\n removeFingerprintOnSuccess : false,\n // Reset the parallelUploads option to not cause recursion.\n parallelUploads : 1,\n metadata : {},\n // Add the header to indicate the this is a partial upload.\n headers : {\n ...this.options.headers,\n 'Upload-Concat': 'partial',\n },\n // Reject or resolve the promise if the upload errors or completes.\n onSuccess : resolve,\n onError : reject,\n // Based in the progress for this partial upload, calculate the progress\n // for the entire final upload.\n onProgress: (newPartProgress) => {\n totalProgress = totalProgress - lastPartProgress + newPartProgress\n lastPartProgress = newPartProgress\n this._emitProgress(totalProgress, totalSize)\n },\n // Wait until every partial upload has an upload URL, so we can add\n // them to the URL storage.\n _onUploadUrlAvailable: () => {\n this._parallelUploadUrls[index] = upload.url\n // Test if all uploads have received an URL\n if (this._parallelUploadUrls.filter(u => !!u).length === parts.length) {\n this._saveUploadInUrlStorage()\n }\n },\n }\n\n const upload = new BaseUpload(value, options)\n upload.start()\n\n // Store the upload in an array, so we can later abort them if necessary.\n this._parallelUploads.push(upload)\n }))\n })\n\n let req\n // Wait until all partial uploads are finished and we can send the POST request for\n // creating the final upload.\n Promise.all(uploads).then(() => {\n req = this._openRequest('POST', this.options.endpoint)\n req.setHeader('Upload-Concat', `final;${this._parallelUploadUrls.join(' ')}`)\n\n // Add metadata if values have been added\n var metadata = encodeMetadata(this.options.metadata)\n if (metadata !== '') {\n req.setHeader('Upload-Metadata', metadata)\n }\n\n return this._sendRequest(req, null)\n }).then((res) => {\n if (!inStatusCategory(res.getStatus(), 200)) {\n this._emitHttpError(req, res, 'tus: unexpected response while creating upload')\n return\n }\n\n const location = res.getHeader('Location')\n if (location == null) {\n this._emitHttpError(req, res, 'tus: invalid or missing Location header')\n return\n }\n\n this.url = resolveUrl(this.options.endpoint, location)\n log(`Created upload at ${this.url}`)\n\n this._emitSuccess()\n }).catch((err) => {\n this._emitError(err)\n })\n }\n\n /**\n * Initiate the uploading procedure for a non-parallel upload. Here the entire file is\n * uploaded in a sequential matter.\n *\n * @api private\n */\n _startSingleUpload () {\n // First, we look at the uploadLengthDeferred option.\n // Next, we check if the caller has supplied a manual upload size.\n // Finally, we try to use the calculated size from the source object.\n if (this.options.uploadLengthDeferred) {\n this._size = null\n } else if (this.options.uploadSize != null) {\n this._size = +this.options.uploadSize\n if (isNaN(this._size)) {\n this._emitError(new Error('tus: cannot convert `uploadSize` option into a number'))\n return\n }\n } else {\n this._size = this._source.size\n if (this._size == null) {\n this._emitError(new Error(\"tus: cannot automatically derive upload's size from input and must be specified manually using the `uploadSize` option\"))\n return\n }\n }\n\n // Reset the aborted flag when the upload is started or else the\n // _performUpload will stop before sending a request if the upload has been\n // aborted previously.\n this._aborted = false\n\n // The upload had been started previously and we should reuse this URL.\n if (this.url != null) {\n log(`Resuming upload from previous URL: ${this.url}`)\n this._resumeUpload()\n return\n }\n\n // A URL has manually been specified, so we try to resume\n if (this.options.uploadUrl != null) {\n log(`Resuming upload from provided URL: ${this.options.url}`)\n this.url = this.options.uploadUrl\n this._resumeUpload()\n return\n }\n\n // An upload has not started for the file yet, so we start a new one\n log('Creating a new upload')\n this._createUpload()\n }\n\n /**\n * Abort any running request and stop the current upload. After abort is called, no event\n * handler will be invoked anymore. You can use the `start` method to resume the upload\n * again.\n * If `shouldTerminate` is true, the `terminate` function will be called to remove the\n * current upload from the server.\n *\n * @param {boolean} shouldTerminate True if the upload should be deleted from the server.\n * @return {Promise} The Promise will be resolved/rejected when the requests finish.\n */\n abort (shouldTerminate) {\n // Count the number of arguments to see if a callback is being provided in the old style required by tus-js-client 1.x, then throw an error if it is.\n // `arguments` is a JavaScript built-in variable that contains all of the function's arguments.\n if (arguments.length > 1 && typeof arguments[1] === 'function') {\n throw new Error('tus: the abort function does not accept a callback since v2 anymore; please use the returned Promise instead')\n }\n\n // Stop any parallel partial uploads, that have been started in _startParallelUploads.\n if (this._parallelUploads != null) {\n this._parallelUploads.forEach((upload) => {\n upload.abort(shouldTerminate)\n })\n }\n\n // Stop any current running request.\n if (this._req !== null) {\n this._req.abort()\n this._source.close()\n }\n this._aborted = true\n\n // Stop any timeout used for initiating a retry.\n if (this._retryTimeout != null) {\n clearTimeout(this._retryTimeout)\n this._retryTimeout = null\n }\n\n if (!shouldTerminate || this.url == null) {\n return Promise.resolve()\n }\n\n return BaseUpload.terminate(this.url, this.options)\n // Remove entry from the URL storage since the upload URL is no longer valid.\n .then(() => this._removeFromUrlStorage())\n }\n\n _emitHttpError (req, res, message, causingErr) {\n this._emitError(new DetailedError(message, causingErr, req, res))\n }\n\n _emitError (err) {\n // Do not emit errors, e.g. from aborted HTTP requests, if the upload has been stopped.\n if (this._aborted) return\n\n // Check if we should retry, when enabled, before sending the error to the user.\n if (this.options.retryDelays != null) {\n // We will reset the attempt counter if\n // - we were already able to connect to the server (offset != null) and\n // - we were able to upload a small chunk of data to the server\n const shouldResetDelays = this._offset != null && (this._offset > this._offsetBeforeRetry)\n if (shouldResetDelays) {\n this._retryAttempt = 0\n }\n\n if (shouldRetry(err, this._retryAttempt, this.options)) {\n const delay = this.options.retryDelays[this._retryAttempt++]\n\n this._offsetBeforeRetry = this._offset\n\n this._retryTimeout = setTimeout(() => {\n this.start()\n }, delay)\n return\n }\n }\n\n if (typeof this.options.onError === 'function') {\n this.options.onError(err)\n } else {\n throw err\n }\n }\n\n /**\n * Publishes notification if the upload has been successfully completed.\n *\n * @api private\n */\n _emitSuccess () {\n if (this.options.removeFingerprintOnSuccess) {\n // Remove stored fingerprint and corresponding endpoint. This causes\n // new uploads of the same file to be treated as a different file.\n this._removeFromUrlStorage()\n }\n\n if (typeof this.options.onSuccess === 'function') {\n this.options.onSuccess()\n }\n }\n\n /**\n * Publishes notification when data has been sent to the server. This\n * data may not have been accepted by the server yet.\n *\n * @param {number} bytesSent Number of bytes sent to the server.\n * @param {number} bytesTotal Total number of bytes to be sent to the server.\n * @api private\n */\n _emitProgress (bytesSent, bytesTotal) {\n if (typeof this.options.onProgress === 'function') {\n this.options.onProgress(bytesSent, bytesTotal)\n }\n }\n\n /**\n * Publishes notification when a chunk of data has been sent to the server\n * and accepted by the server.\n * @param {number} chunkSize Size of the chunk that was accepted by the server.\n * @param {number} bytesAccepted Total number of bytes that have been\n * accepted by the server.\n * @param {number} bytesTotal Total number of bytes to be sent to the server.\n * @api private\n */\n _emitChunkComplete (chunkSize, bytesAccepted, bytesTotal) {\n if (typeof this.options.onChunkComplete === 'function') {\n this.options.onChunkComplete(chunkSize, bytesAccepted, bytesTotal)\n }\n }\n\n /**\n * Create a new upload using the creation extension by sending a POST\n * request to the endpoint. After successful creation the file will be\n * uploaded\n *\n * @api private\n */\n _createUpload () {\n if (!this.options.endpoint) {\n this._emitError(new Error('tus: unable to create upload because no endpoint is provided'))\n return\n }\n\n const req = this._openRequest('POST', this.options.endpoint)\n\n if (this.options.uploadLengthDeferred) {\n req.setHeader('Upload-Defer-Length', 1)\n } else {\n req.setHeader('Upload-Length', this._size)\n }\n\n // Add metadata if values have been added\n var metadata = encodeMetadata(this.options.metadata)\n if (metadata !== '') {\n req.setHeader('Upload-Metadata', metadata)\n }\n\n let promise\n if (this.options.uploadDataDuringCreation && !this.options.uploadLengthDeferred) {\n this._offset = 0\n promise = this._addChunkToRequest(req)\n } else {\n promise = this._sendRequest(req, null)\n }\n\n promise.then((res) => {\n if (!inStatusCategory(res.getStatus(), 200)) {\n this._emitHttpError(req, res, 'tus: unexpected response while creating upload')\n return\n }\n\n const location = res.getHeader('Location')\n if (location == null) {\n this._emitHttpError(req, res, 'tus: invalid or missing Location header')\n return\n }\n\n this.url = resolveUrl(this.options.endpoint, location)\n log(`Created upload at ${this.url}`)\n\n if (typeof this.options._onUploadUrlAvailable === 'function') {\n this.options._onUploadUrlAvailable()\n }\n\n if (this._size === 0) {\n // Nothing to upload and file was successfully created\n this._emitSuccess()\n this._source.close()\n return\n }\n\n this._saveUploadInUrlStorage()\n\n if (this.options.uploadDataDuringCreation) {\n this._handleUploadResponse(req, res)\n } else {\n this._offset = 0\n this._performUpload()\n }\n }).catch((err) => {\n this._emitHttpError(req, null, 'tus: failed to create upload', err)\n })\n }\n\n /*\n * Try to resume an existing upload. First a HEAD request will be sent\n * to retrieve the offset. If the request fails a new upload will be\n * created. In the case of a successful response the file will be uploaded.\n *\n * @api private\n */\n _resumeUpload () {\n const req = this._openRequest('HEAD', this.url)\n const promise = this._sendRequest(req, null)\n\n promise.then((res) => {\n const status = res.getStatus()\n if (!inStatusCategory(status, 200)) {\n if (inStatusCategory(status, 400)) {\n // Remove stored fingerprint and corresponding endpoint,\n // on client errors since the file can not be found\n this._removeFromUrlStorage()\n }\n\n // If the upload is locked (indicated by the 423 Locked status code), we\n // emit an error instead of directly starting a new upload. This way the\n // retry logic can catch the error and will retry the upload. An upload\n // is usually locked for a short period of time and will be available\n // afterwards.\n if (status === 423) {\n this._emitHttpError(req, res, 'tus: upload is currently locked; retry later')\n return\n }\n\n if (!this.options.endpoint) {\n // Don't attempt to create a new upload if no endpoint is provided.\n this._emitHttpError(req, res, 'tus: unable to resume upload (new upload cannot be created without an endpoint)')\n return\n }\n\n // Try to create a new upload\n this.url = null\n this._createUpload()\n return\n }\n\n const offset = parseInt(res.getHeader('Upload-Offset'), 10)\n if (isNaN(offset)) {\n this._emitHttpError(req, res, 'tus: invalid or missing offset value')\n return\n }\n\n const length = parseInt(res.getHeader('Upload-Length'), 10)\n if (isNaN(length) && !this.options.uploadLengthDeferred) {\n this._emitHttpError(req, res, 'tus: invalid or missing length value')\n return\n }\n\n if (typeof this.options._onUploadUrlAvailable === 'function') {\n this.options._onUploadUrlAvailable()\n }\n\n // Upload has already been completed and we do not need to send additional\n // data to the server\n if (offset === length) {\n this._emitProgress(length, length)\n this._emitSuccess()\n return\n }\n\n this._offset = offset\n this._performUpload()\n }).catch((err) => {\n this._emitHttpError(req, null, 'tus: failed to resume upload', err)\n })\n }\n\n /**\n * Start uploading the file using PATCH requests. The file will be divided\n * into chunks as specified in the chunkSize option. During the upload\n * the onProgress event handler may be invoked multiple times.\n *\n * @api private\n */\n _performUpload () {\n // If the upload has been aborted, we will not send the next PATCH request.\n // This is important if the abort method was called during a callback, such\n // as onChunkComplete or onProgress.\n if (this._aborted) {\n return\n }\n\n let req\n\n // Some browser and servers may not support the PATCH method. For those\n // cases, you can tell tus-js-client to use a POST request with the\n // X-HTTP-Method-Override header for simulating a PATCH request.\n if (this.options.overridePatchMethod) {\n req = this._openRequest('POST', this.url)\n req.setHeader('X-HTTP-Method-Override', 'PATCH')\n } else {\n req = this._openRequest('PATCH', this.url)\n }\n\n req.setHeader('Upload-Offset', this._offset)\n const promise = this._addChunkToRequest(req)\n\n promise.then((res) => {\n if (!inStatusCategory(res.getStatus(), 200)) {\n this._emitHttpError(req, res, 'tus: unexpected response while uploading chunk')\n return\n }\n\n this._handleUploadResponse(req, res)\n }).catch((err) => {\n // Don't emit an error if the upload was aborted manually\n if (this._aborted) {\n return\n }\n\n this._emitHttpError(req, null, `tus: failed to upload chunk at offset ${this._offset}`, err)\n })\n }\n\n /**\n * _addChunktoRequest reads a chunk from the source and sends it using the\n * supplied request object. It will not handle the response.\n *\n * @api private\n */\n _addChunkToRequest (req) {\n const start = this._offset\n let end = this._offset + this.options.chunkSize\n\n req.setProgressHandler((bytesSent) => {\n this._emitProgress(start + bytesSent, this._size)\n })\n\n req.setHeader('Content-Type', 'application/offset+octet-stream')\n\n // The specified chunkSize may be Infinity or the calcluated end position\n // may exceed the file's size. In both cases, we limit the end position to\n // the input's total size for simpler calculations and correctness.\n if ((end === Infinity || end > this._size) && !this.options.uploadLengthDeferred) {\n end = this._size\n }\n\n return this._source.slice(start, end)\n .then(({ value, done }) => {\n // If the upload length is deferred, the upload size was not specified during\n // upload creation. So, if the file reader is done reading, we know the total\n // upload size and can tell the tus server.\n if (this.options.uploadLengthDeferred && done) {\n this._size = this._offset + (value && value.size ? value.size : 0)\n req.setHeader('Upload-Length', this._size)\n }\n\n if (value === null) {\n return this._sendRequest(req)\n }\n this._emitProgress(this._offset, this._size)\n return this._sendRequest(req, value)\n })\n }\n\n /**\n * _handleUploadResponse is used by requests that haven been sent using _addChunkToRequest\n * and already have received a response.\n *\n * @api private\n */\n _handleUploadResponse (req, res) {\n const offset = parseInt(res.getHeader('Upload-Offset'), 10)\n if (isNaN(offset)) {\n this._emitHttpError(req, res, 'tus: invalid or missing offset value')\n return\n }\n\n this._emitProgress(offset, this._size)\n this._emitChunkComplete(offset - this._offset, offset, this._size)\n\n this._offset = offset\n\n if (offset == this._size) {\n // Yay, finally done :)\n this._emitSuccess()\n this._source.close()\n return\n }\n\n this._performUpload()\n }\n\n /**\n * Create a new HTTP request object with the given method and URL.\n *\n * @api private\n */\n _openRequest (method, url) {\n const req = openRequest(method, url, this.options)\n this._req = req\n return req\n }\n\n /**\n * Remove the entry in the URL storage, if it has been saved before.\n *\n * @api private\n */\n _removeFromUrlStorage () {\n if (!this._urlStorageKey) return\n\n this._urlStorage.removeUpload(this._urlStorageKey).catch((err) => {\n this._emitError(err)\n })\n this._urlStorageKey = null\n }\n\n /**\n * Add the upload URL to the URL storage, if possible.\n *\n * @api private\n */\n _saveUploadInUrlStorage () {\n // Only if a fingerprint was calculated for the input (i.e. not a stream), we can store the upload URL.\n if (!this.options.storeFingerprintForResuming || !this._fingerprint) {\n return\n }\n\n const storedUpload = {\n size : this._size,\n metadata : this.options.metadata,\n creationTime: new Date().toString(),\n }\n\n if (this._parallelUploads) {\n // Save multiple URLs if the parallelUploads option is used ...\n storedUpload.parallelUploadUrls = this._parallelUploadUrls\n } else {\n // ... otherwise we just save the one available URL.\n storedUpload.uploadUrl = this.url\n }\n\n this._urlStorage.addUpload(this._fingerprint, storedUpload)\n .then((urlStorageKey) => this._urlStorageKey = urlStorageKey)\n .catch((err) => {\n this._emitError(err)\n })\n }\n\n /**\n * Send a request with the provided body.\n *\n * @api private\n */\n _sendRequest (req, body = null) {\n return sendRequest(req, body, this.options)\n }\n}\n\nfunction encodeMetadata (metadata) {\n var encoded = []\n\n for (var key in metadata) {\n encoded.push(`${key} ${Base64.encode(metadata[key])}`)\n }\n\n return encoded.join(',')\n}\n\n/**\n * Checks whether a given status is in the range of the expected category.\n * For example, only a status between 200 and 299 will satisfy the category 200.\n *\n * @api private\n */\nfunction inStatusCategory (status, category) {\n return (status >= category && status < (category + 100))\n}\n\n/**\n * Create a new HTTP request with the specified method and URL.\n * The necessary headers that are included in every request\n * will be added, including the request ID.\n *\n * @api private\n */\nfunction openRequest (method, url, options) {\n const req = options.httpStack.createRequest(method, url)\n\n req.setHeader('Tus-Resumable', '1.0.0')\n const headers = options.headers || {}\n\n for (const name in headers) {\n req.setHeader(name, headers[name])\n }\n\n if (options.addRequestId) {\n const requestId = uuid()\n req.setHeader('X-Request-ID', requestId)\n }\n\n return req\n}\n\n/**\n * Send a request with the provided body while invoking the onBeforeRequest\n * and onAfterResponse callbacks.\n *\n * @api private\n */\nfunction sendRequest (req, body, options) {\n const onBeforeRequestPromise = (typeof options.onBeforeRequest === 'function')\n ? Promise.resolve(options.onBeforeRequest(req))\n : Promise.resolve()\n\n return onBeforeRequestPromise.then(() => {\n return req.send(body)\n .then((res) => {\n const onAfterResponsePromise = (typeof options.onAfterResponse === 'function')\n ? Promise.resolve(options.onAfterResponse(req, res))\n : Promise.resolve()\n\n return onAfterResponsePromise.then(() => res)\n })\n })\n}\n\n/**\n * Checks whether the browser running this code has internet access.\n * This function will always return true in the node.js environment\n *\n * @api private\n */\nfunction isOnline () {\n let online = true\n if (typeof window !== 'undefined'\n && 'navigator' in window\n && window.navigator.onLine === false) {\n online = false\n }\n\n return online\n}\n\n/**\n * Checks whether or not it is ok to retry a request.\n * @param {Error} err the error returned from the last request\n * @param {number} retryAttempt the number of times the request has already been retried\n * @param {object} options tus Upload options\n *\n * @api private\n */\nfunction shouldRetry (err, retryAttempt, options) {\n // We only attempt a retry if\n // - retryDelays option is set\n // - we didn't exceed the maxium number of retries, yet, and\n // - this error was caused by a request or it's response and\n // - the error is server error (i.e. not a status 4xx except a 409 or 423) or\n // a onShouldRetry is specified and returns true\n // - the browser does not indicate that we are offline\n if (options.retryDelays == null || retryAttempt >= options.retryDelays.length || err.originalRequest == null) {\n return false\n }\n\n if (options && typeof options.onShouldRetry === 'function') {\n return options.onShouldRetry(err, retryAttempt, options)\n }\n\n const status = err.originalResponse ? err.originalResponse.getStatus() : 0\n return (!inStatusCategory(status, 400) || status === 409 || status === 423) && isOnline()\n}\n\n/**\n * Resolve a relative link given the origin as source. For example,\n * if a HTTP request to http://example.com/files/ returns a Location\n * header with the value /upload/abc, the resolved URL will be:\n * http://example.com/upload/abc\n */\nfunction resolveUrl (origin, link) {\n return new URL(link, origin).toString()\n}\n\n/**\n * Calculate the start and end positions for the parts if an upload\n * is split into multiple parallel requests.\n *\n * @param {number} totalSize The byte size of the upload, which will be split.\n * @param {number} partCount The number in how many parts the upload will be split.\n * @param {string[]} previousUrls The upload URLs for previous parts.\n * @return {object[]}\n * @api private\n */\nfunction splitSizeIntoParts (totalSize, partCount, previousUrls) {\n const partSize = Math.floor(totalSize / partCount)\n const parts = []\n\n for (let i = 0; i < partCount; i++) {\n parts.push({\n start: partSize * i,\n end : partSize * (i + 1),\n })\n }\n\n parts[partCount - 1].end = totalSize\n\n // Attach URLs from previous uploads, if available.\n if (previousUrls) {\n parts.forEach((part, index) => {\n part.uploadUrl = previousUrls[index] || null\n })\n }\n\n return parts\n}\n\nBaseUpload.defaultOptions = defaultOptions\n\nexport default BaseUpload\n", "/**\n * Generate a UUID v4 based on random numbers. We intentioanlly use the less\n * secure Math.random function here since the more secure crypto.getRandomNumbers\n * is not available on all platforms.\n * This is not a problem for us since we use the UUID only for generating a\n * request ID, so we can correlate server logs to client errors.\n *\n * This function is taken from following site:\n * https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript\n *\n * @return {string} The generate UUID\n */\nexport default function uuid () {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n var r = Math.random() * 16 | 0,\n v = c == 'x' ? r : (r & 0x3 | 0x8)\n return v.toString(16)\n })\n}\n", "/*\n * base64.js\n *\n * Licensed under the BSD 3-Clause License.\n * http://opensource.org/licenses/BSD-3-Clause\n *\n * References:\n * http://en.wikipedia.org/wiki/Base64\n */\n;(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined'\n ? module.exports = factory(global)\n : typeof define === 'function' && define.amd\n ? define(factory) : factory(global)\n}((\n typeof self !== 'undefined' ? self\n : typeof window !== 'undefined' ? window\n : typeof global !== 'undefined' ? global\n: this\n), function(global) {\n 'use strict';\n // existing version for noConflict()\n global = global || {};\n var _Base64 = global.Base64;\n var version = \"2.6.1\";\n // constants\n var b64chars\n = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n var b64tab = function(bin) {\n var t = {};\n for (var i = 0, l = bin.length; i < l; i++) t[bin.charAt(i)] = i;\n return t;\n }(b64chars);\n var fromCharCode = String.fromCharCode;\n // encoder stuff\n var cb_utob = function(c) {\n if (c.length < 2) {\n var cc = c.charCodeAt(0);\n return cc < 0x80 ? c\n : cc < 0x800 ? (fromCharCode(0xc0 | (cc >>> 6))\n + fromCharCode(0x80 | (cc & 0x3f)))\n : (fromCharCode(0xe0 | ((cc >>> 12) & 0x0f))\n + fromCharCode(0x80 | ((cc >>> 6) & 0x3f))\n + fromCharCode(0x80 | ( cc & 0x3f)));\n } else {\n var cc = 0x10000\n + (c.charCodeAt(0) - 0xD800) * 0x400\n + (c.charCodeAt(1) - 0xDC00);\n return (fromCharCode(0xf0 | ((cc >>> 18) & 0x07))\n + fromCharCode(0x80 | ((cc >>> 12) & 0x3f))\n + fromCharCode(0x80 | ((cc >>> 6) & 0x3f))\n + fromCharCode(0x80 | ( cc & 0x3f)));\n }\n };\n var re_utob = /[\\uD800-\\uDBFF][\\uDC00-\\uDFFFF]|[^\\x00-\\x7F]/g;\n var utob = function(u) {\n return u.replace(re_utob, cb_utob);\n };\n var cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3],\n ord = ccc.charCodeAt(0) << 16\n | ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8)\n | ((ccc.length > 2 ? ccc.charCodeAt(2) : 0)),\n chars = [\n b64chars.charAt( ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n };\n var btoa = global.btoa && typeof global.btoa == 'function'\n ? function(b){ return global.btoa(b) } : function(b) {\n if (b.match(/[^\\x00-\\xFF]/)) throw new RangeError(\n 'The string contains invalid characters.'\n );\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n var _encode = function(u) {\n return btoa(utob(String(u)));\n };\n var encode = function(u, urisafe) {\n return !urisafe\n ? _encode(String(u))\n : _encode(String(u)).replace(/[+\\/]/g, function(m0) {\n return m0 == '+' ? '-' : '_';\n }).replace(/=/g, '');\n };\n var encodeURI = function(u) { return encode(u, true) };\n var fromUint8Array = function(a) {\n return btoa(Array.from(a, function(c) {\n return String.fromCharCode(c)\n }).join(''));\n };\n // decoder stuff\n var re_btou = /[\\xC0-\\xDF][\\x80-\\xBF]|[\\xE0-\\xEF][\\x80-\\xBF]{2}|[\\xF0-\\xF7][\\x80-\\xBF]{3}/g;\n var cb_btou = function(cccc) {\n switch(cccc.length) {\n case 4:\n var cp = ((0x07 & cccc.charCodeAt(0)) << 18)\n | ((0x3f & cccc.charCodeAt(1)) << 12)\n | ((0x3f & cccc.charCodeAt(2)) << 6)\n | (0x3f & cccc.charCodeAt(3)),\n offset = cp - 0x10000;\n return (fromCharCode((offset >>> 10) + 0xD800)\n + fromCharCode((offset & 0x3FF) + 0xDC00));\n case 3:\n return fromCharCode(\n ((0x0f & cccc.charCodeAt(0)) << 12)\n | ((0x3f & cccc.charCodeAt(1)) << 6)\n | (0x3f & cccc.charCodeAt(2))\n );\n default:\n return fromCharCode(\n ((0x1f & cccc.charCodeAt(0)) << 6)\n | (0x3f & cccc.charCodeAt(1))\n );\n }\n };\n var btou = function(b) {\n return b.replace(re_btou, cb_btou);\n };\n var cb_decode = function(cccc) {\n var len = cccc.length,\n padlen = len % 4,\n n = (len > 0 ? b64tab[cccc.charAt(0)] << 18 : 0)\n | (len > 1 ? b64tab[cccc.charAt(1)] << 12 : 0)\n | (len > 2 ? b64tab[cccc.charAt(2)] << 6 : 0)\n | (len > 3 ? b64tab[cccc.charAt(3)] : 0),\n chars = [\n fromCharCode( n >>> 16),\n fromCharCode((n >>> 8) & 0xff),\n fromCharCode( n & 0xff)\n ];\n chars.length -= [0, 0, 2, 1][padlen];\n return chars.join('');\n };\n var _atob = global.atob && typeof global.atob == 'function'\n ? function(a){ return global.atob(a) } : function(a){\n return a.replace(/\\S{1,4}/g, cb_decode);\n };\n var atob = function(a) {\n return _atob(String(a).replace(/[^A-Za-z0-9\\+\\/]/g, ''));\n };\n var _decode = function(a) { return btou(_atob(a)) };\n var decode = function(a){\n return _decode(\n String(a).replace(/[-_]/g, function(m0) {\n return m0 == '-' ? '+' : '/'\n }).replace(/[^A-Za-z0-9\\+\\/]/g, '')\n );\n };\n var toUint8Array = function(a) {\n return Uint8Array.from(atob(a), function(c) {\n return c.charCodeAt(0);\n });\n };\n var noConflict = function() {\n var Base64 = global.Base64;\n global.Base64 = _Base64;\n return Base64;\n };\n // export Base64\n global.Base64 = {\n VERSION: version,\n atob: atob,\n btoa: btoa,\n fromBase64: decode,\n toBase64: encode,\n utob: utob,\n encode: encode,\n encodeURI: encodeURI,\n btou: btou,\n decode: decode,\n noConflict: noConflict,\n fromUint8Array: fromUint8Array,\n toUint8Array: toUint8Array\n };\n // if ES5 is available, make Base64.extendString() available\n if (typeof Object.defineProperty === 'function') {\n var noEnum = function(v){\n return {value:v,enumerable:false,writable:true,configurable:true};\n };\n global.Base64.extendString = function () {\n Object.defineProperty(\n String.prototype, 'fromBase64', noEnum(function () {\n return decode(this)\n }));\n Object.defineProperty(\n String.prototype, 'toBase64', noEnum(function (urisafe) {\n return encode(this, urisafe)\n }));\n Object.defineProperty(\n String.prototype, 'toBase64URI', noEnum(function () {\n return encode(this, true)\n }));\n };\n }\n //\n // export Base64 to the namespace\n //\n if (global['Meteor']) { // Meteor.js\n Base64 = global.Base64;\n }\n // module.exports and AMD are mutually exclusive.\n // module.exports has precedence.\n if (typeof module !== 'undefined' && module.exports) {\n module.exports.Base64 = global.Base64;\n }\n else if (typeof define === 'function' && define.amd) {\n // AMD. Register as an anonymous module.\n define([], function(){ return global.Base64 });\n }\n // that's it!\n return {Base64: global.Base64}\n}));\n", "'use strict';\n\nvar has = Object.prototype.hasOwnProperty;\n\n/**\n * Decode a URI encoded string.\n *\n * @param {String} input The URI encoded string.\n * @returns {String} The decoded string.\n * @api private\n */\nfunction decode(input) {\n return decodeURIComponent(input.replace(/\\+/g, ' '));\n}\n\n/**\n * Simple query string parser.\n *\n * @param {String} query The query string that needs to be parsed.\n * @returns {Object}\n * @api public\n */\nfunction querystring(query) {\n var parser = /([^=?&]+)=?([^&]*)/g\n , result = {}\n , part;\n\n while (part = parser.exec(query)) {\n var key = decode(part[1])\n , value = decode(part[2]);\n\n //\n // Prevent overriding of existing properties. This ensures that build-in\n // methods like `toString` or __proto__ are not overriden by malicious\n // querystrings.\n //\n if (key in result) continue;\n result[key] = value;\n }\n\n return result;\n}\n\n/**\n * Transform a query string to an object.\n *\n * @param {Object} obj Object that should be transformed.\n * @param {String} prefix Optional prefix.\n * @returns {String}\n * @api public\n */\nfunction querystringify(obj, prefix) {\n prefix = prefix || '';\n\n var pairs = [];\n\n //\n // Optionally prefix with a '?' if needed\n //\n if ('string' !== typeof prefix) prefix = '?';\n\n for (var key in obj) {\n if (has.call(obj, key)) {\n pairs.push(encodeURIComponent(key) +'='+ encodeURIComponent(obj[key]));\n }\n }\n\n return pairs.length ? prefix + pairs.join('&') : '';\n}\n\n//\n// Expose the module.\n//\nexports.stringify = querystringify;\nexports.parse = querystring;\n", "'use strict';\n\n/**\n * Check if we're required to add a port number.\n *\n * @see https://url.spec.whatwg.org/#default-port\n * @param {Number|String} port Port number we need to check\n * @param {String} protocol Protocol we need to check against.\n * @returns {Boolean} Is it a default port for the given protocol\n * @api private\n */\nmodule.exports = function required(port, protocol) {\n protocol = protocol.split(':')[0];\n port = +port;\n\n if (!port) return false;\n\n switch (protocol) {\n case 'http':\n case 'ws':\n return port !== 80;\n\n case 'https':\n case 'wss':\n return port !== 443;\n\n case 'ftp':\n return port !== 21;\n\n case 'gopher':\n return port !== 70;\n\n case 'file':\n return false;\n }\n\n return port !== 0;\n};\n", "'use strict';\n\nvar required = require('requires-port')\n , qs = require('querystringify')\n , protocolre = /^([a-z][a-z0-9.+-]*:)?(\\/\\/)?([\\S\\s]*)/i\n , slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\\/\\//;\n\n/**\n * These are the parse rules for the URL parser, it informs the parser\n * about:\n *\n * 0. The char it Needs to parse, if it's a string it should be done using\n * indexOf, RegExp using exec and NaN means set as current value.\n * 1. The property we should set when parsing this value.\n * 2. Indication if it's backwards or forward parsing, when set as number it's\n * the value of extra chars that should be split off.\n * 3. Inherit from location if non existing in the parser.\n * 4. `toLowerCase` the resulting value.\n */\nvar rules = [\n ['#', 'hash'], // Extract from the back.\n ['?', 'query'], // Extract from the back.\n function sanitize(address) { // Sanitize what is left of the address\n return address.replace('\\\\', '/');\n },\n ['/', 'pathname'], // Extract from the back.\n ['@', 'auth', 1], // Extract from the front.\n [NaN, 'host', undefined, 1, 1], // Set left over value.\n [/:(\\d+)$/, 'port', undefined, 1], // RegExp the back.\n [NaN, 'hostname', undefined, 1, 1] // Set left over.\n];\n\n/**\n * These properties should not be copied or inherited from. This is only needed\n * for all non blob URL's as a blob URL does not include a hash, only the\n * origin.\n *\n * @type {Object}\n * @private\n */\nvar ignore = { hash: 1, query: 1 };\n\n/**\n * The location object differs when your code is loaded through a normal page,\n * Worker or through a worker using a blob. And with the blobble begins the\n * trouble as the location object will contain the URL of the blob, not the\n * location of the page where our code is loaded in. The actual origin is\n * encoded in the `pathname` so we can thankfully generate a good \"default\"\n * location from it so we can generate proper relative URL's again.\n *\n * @param {Object|String} loc Optional default location object.\n * @returns {Object} lolcation object.\n * @public\n */\nfunction lolcation(loc) {\n var location = global && global.location || {};\n loc = loc || location;\n\n var finaldestination = {}\n , type = typeof loc\n , key;\n\n if ('blob:' === loc.protocol) {\n finaldestination = new Url(unescape(loc.pathname), {});\n } else if ('string' === type) {\n finaldestination = new Url(loc, {});\n for (key in ignore) delete finaldestination[key];\n } else if ('object' === type) {\n for (key in loc) {\n if (key in ignore) continue;\n finaldestination[key] = loc[key];\n }\n\n if (finaldestination.slashes === undefined) {\n finaldestination.slashes = slashes.test(loc.href);\n }\n }\n\n return finaldestination;\n}\n\n/**\n * @typedef ProtocolExtract\n * @type Object\n * @property {String} protocol Protocol matched in the URL, in lowercase.\n * @property {Boolean} slashes `true` if protocol is followed by \"//\", else `false`.\n * @property {String} rest Rest of the URL that is not part of the protocol.\n */\n\n/**\n * Extract protocol information from a URL with/without double slash (\"//\").\n *\n * @param {String} address URL we want to extract from.\n * @return {ProtocolExtract} Extracted information.\n * @private\n */\nfunction extractProtocol(address) {\n var match = protocolre.exec(address);\n\n return {\n protocol: match[1] ? match[1].toLowerCase() : '',\n slashes: !!match[2],\n rest: match[3]\n };\n}\n\n/**\n * Resolve a relative URL pathname against a base URL pathname.\n *\n * @param {String} relative Pathname of the relative URL.\n * @param {String} base Pathname of the base URL.\n * @return {String} Resolved pathname.\n * @private\n */\nfunction resolve(relative, base) {\n var path = (base || '/').split('/').slice(0, -1).concat(relative.split('/'))\n , i = path.length\n , last = path[i - 1]\n , unshift = false\n , up = 0;\n\n while (i--) {\n if (path[i] === '.') {\n path.splice(i, 1);\n } else if (path[i] === '..') {\n path.splice(i, 1);\n up++;\n } else if (up) {\n if (i === 0) unshift = true;\n path.splice(i, 1);\n up--;\n }\n }\n\n if (unshift) path.unshift('');\n if (last === '.' || last === '..') path.push('');\n\n return path.join('/');\n}\n\n/**\n * The actual URL instance. Instead of returning an object we've opted-in to\n * create an actual constructor as it's much more memory efficient and\n * faster and it pleases my OCD.\n *\n * It is worth noting that we should not use `URL` as class name to prevent\n * clashes with the global URL instance that got introduced in browsers.\n *\n * @constructor\n * @param {String} address URL we want to parse.\n * @param {Object|String} location Location defaults for relative paths.\n * @param {Boolean|Function} parser Parser for the query string.\n * @private\n */\nfunction Url(address, location, parser) {\n if (!(this instanceof Url)) {\n return new Url(address, location, parser);\n }\n\n var relative, extracted, parse, instruction, index, key\n , instructions = rules.slice()\n , type = typeof location\n , url = this\n , i = 0;\n\n //\n // The following if statements allows this module two have compatibility with\n // 2 different API:\n //\n // 1. Node.js's `url.parse` api which accepts a URL, boolean as arguments\n // where the boolean indicates that the query string should also be parsed.\n //\n // 2. The `URL` interface of the browser which accepts a URL, object as\n // arguments. The supplied object will be used as default values / fall-back\n // for relative paths.\n //\n if ('object' !== type && 'string' !== type) {\n parser = location;\n location = null;\n }\n\n if (parser && 'function' !== typeof parser) parser = qs.parse;\n\n location = lolcation(location);\n\n //\n // Extract protocol information before running the instructions.\n //\n extracted = extractProtocol(address || '');\n relative = !extracted.protocol && !extracted.slashes;\n url.slashes = extracted.slashes || relative && location.slashes;\n url.protocol = extracted.protocol || location.protocol || '';\n address = extracted.rest;\n\n //\n // When the authority component is absent the URL starts with a path\n // component.\n //\n if (!extracted.slashes) instructions[3] = [/(.*)/, 'pathname'];\n\n for (; i < instructions.length; i++) {\n instruction = instructions[i];\n\n if (typeof instruction === 'function') {\n address = instruction(address);\n continue;\n }\n\n parse = instruction[0];\n key = instruction[1];\n\n if (parse !== parse) {\n url[key] = address;\n } else if ('string' === typeof parse) {\n if (~(index = address.indexOf(parse))) {\n if ('number' === typeof instruction[2]) {\n url[key] = address.slice(0, index);\n address = address.slice(index + instruction[2]);\n } else {\n url[key] = address.slice(index);\n address = address.slice(0, index);\n }\n }\n } else if ((index = parse.exec(address))) {\n url[key] = index[1];\n address = address.slice(0, index.index);\n }\n\n url[key] = url[key] || (\n relative && instruction[3] ? location[key] || '' : ''\n );\n\n //\n // Hostname, host and protocol should be lowercased so they can be used to\n // create a proper `origin`.\n //\n if (instruction[4]) url[key] = url[key].toLowerCase();\n }\n\n //\n // Also parse the supplied query string in to an object. If we're supplied\n // with a custom parser as function use that instead of the default build-in\n // parser.\n //\n if (parser) url.query = parser(url.query);\n\n //\n // If the URL is relative, resolve the pathname against the base URL.\n //\n if (\n relative\n && location.slashes\n && url.pathname.charAt(0) !== '/'\n && (url.pathname !== '' || location.pathname !== '')\n ) {\n url.pathname = resolve(url.pathname, location.pathname);\n }\n\n //\n // We should not add port numbers if they are already the default port number\n // for a given protocol. As the host also contains the port number we're going\n // override it with the hostname which contains no port number.\n //\n if (!required(url.port, url.protocol)) {\n url.host = url.hostname;\n url.port = '';\n }\n\n //\n // Parse down the `auth` for the username and password.\n //\n url.username = url.password = '';\n if (url.auth) {\n instruction = url.auth.split(':');\n url.username = instruction[0] || '';\n url.password = instruction[1] || '';\n }\n\n url.origin = url.protocol && url.host && url.protocol !== 'file:'\n ? url.protocol +'//'+ url.host\n : 'null';\n\n //\n // The href is just the compiled result.\n //\n url.href = url.toString();\n}\n\n/**\n * This is convenience method for changing properties in the URL instance to\n * insure that they all propagate correctly.\n *\n * @param {String} part Property we need to adjust.\n * @param {Mixed} value The newly assigned value.\n * @param {Boolean|Function} fn When setting the query, it will be the function\n * used to parse the query.\n * When setting the protocol, double slash will be\n * removed from the final url if it is true.\n * @returns {URL} URL instance for chaining.\n * @public\n */\nfunction set(part, value, fn) {\n var url = this;\n\n switch (part) {\n case 'query':\n if ('string' === typeof value && value.length) {\n value = (fn || qs.parse)(value);\n }\n\n url[part] = value;\n break;\n\n case 'port':\n url[part] = value;\n\n if (!required(value, url.protocol)) {\n url.host = url.hostname;\n url[part] = '';\n } else if (value) {\n url.host = url.hostname +':'+ value;\n }\n\n break;\n\n case 'hostname':\n url[part] = value;\n\n if (url.port) value += ':'+ url.port;\n url.host = value;\n break;\n\n case 'host':\n url[part] = value;\n\n if (/:\\d+$/.test(value)) {\n value = value.split(':');\n url.port = value.pop();\n url.hostname = value.join(':');\n } else {\n url.hostname = value;\n url.port = '';\n }\n\n break;\n\n case 'protocol':\n url.protocol = value.toLowerCase();\n url.slashes = !fn;\n break;\n\n case 'pathname':\n case 'hash':\n if (value) {\n var char = part === 'pathname' ? '/' : '#';\n url[part] = value.charAt(0) !== char ? char + value : value;\n } else {\n url[part] = value;\n }\n break;\n\n default:\n url[part] = value;\n }\n\n for (var i = 0; i < rules.length; i++) {\n var ins = rules[i];\n\n if (ins[4]) url[ins[1]] = url[ins[1]].toLowerCase();\n }\n\n url.origin = url.protocol && url.host && url.protocol !== 'file:'\n ? url.protocol +'//'+ url.host\n : 'null';\n\n url.href = url.toString();\n\n return url;\n}\n\n/**\n * Transform the properties back in to a valid and full URL string.\n *\n * @param {Function} stringify Optional query stringify function.\n * @returns {String} Compiled version of the URL.\n * @public\n */\nfunction toString(stringify) {\n if (!stringify || 'function' !== typeof stringify) stringify = qs.stringify;\n\n var query\n , url = this\n , protocol = url.protocol;\n\n if (protocol && protocol.charAt(protocol.length - 1) !== ':') protocol += ':';\n\n var result = protocol + (url.slashes ? '//' : '');\n\n if (url.username) {\n result += url.username;\n if (url.password) result += ':'+ url.password;\n result += '@';\n }\n\n result += url.host + url.pathname;\n\n query = 'object' === typeof url.query ? stringify(url.query) : url.query;\n if (query) result += '?' !== query.charAt(0) ? '?'+ query : query;\n\n if (url.hash) result += url.hash;\n\n return result;\n}\n\nUrl.prototype = { set: set, toString: toString };\n\n//\n// Expose the URL parser and some additional properties that might be useful for\n// others or testing.\n//\nUrl.extractProtocol = extractProtocol;\nUrl.location = lolcation;\nUrl.qs = qs;\n\nmodule.exports = Url;\n" ] }