rsnext/packages/next/compiled/send/index.js

1 line
63 KiB
JavaScript
Raw Normal View History

module.exports=function(a,t){"use strict";var e={};function __webpack_require__(t){if(e[t]){return e[t].exports}var i=e[t]={i:t,l:false,exports:{}};a[t].call(i.exports,i,i.exports,__webpack_require__);i.l=true;return i.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(202)}return startup()}({143:function(a){"use strict";var t=/["'&<>]/;a.exports=escapeHtml;function escapeHtml(a){var e=""+a;var i=t.exec(e);if(!i){return e}var n;var r="";var o=0;var p=0;for(o=i.index;o<e.length;o++){switch(e.charCodeAt(o)){case 34:n="&quot;";break;case 38:n="&amp;";break;case 39:n="&#39;";break;case 60:n="&lt;";break;case 62:n="&gt;";break;default:continue}if(p!==o){r+=e.substring(p,o)}p=o+1;r+=n}return p!==o?r+e.substring(p,o):r}},185:function(a){a.exports=require("next/dist/compiled/debug")},202:function(a,t,e){"use strict";var i=e(630);var n=e(185)("send");var r=e(319)("send");var o=e(675);var p=e(324);var s=e(143);var c=e(299);var l=e(554);var d=e(747);var m=e(548);var u=e(530);var v=e(247);var f=e(409);var x=e(622);var g=e(839);var h=e(413);var b=e(669);var y=x.extname;var w=x.join;var k=x.normalize;var S=x.resolve;var _=x.sep;var j=/^ *bytes=/;var E=60*60*24*365*1e3;var C=/(?:^|[\\/])\.\.(?:[\\/]|$)/;a.exports=send;a.exports.mime=m;function send(a,t,e){return new SendStream(a,t,e)}function SendStream(a,t,e){h.call(this);var i=e||{};this.options=i;this.path=t;this.req=a;this._acceptRanges=i.acceptRanges!==undefined?Boolean(i.acceptRanges):true;this._cacheControl=i.cacheControl!==undefined?Boolean(i.cacheControl):true;this._etag=i.etag!==undefined?Boolean(i.etag):true;this._dotfiles=i.dotfiles!==undefined?i.dotfiles:"ignore";if(this._dotfiles!=="ignore"&&this._dotfiles!=="allow"&&this._dotfiles!=="deny"){throw new TypeError('dotfiles option must be "allow", "deny", or "ignore"')}this._hidden=Boolean(i.hidden);if(i.hidden!==undefined){r("hidden: use dotfiles: '"+(this._hidden?"allow":"ignore")+"' instead")}if(i.dotfiles===undefined){this._dotfiles=undefined}this._extensions=i.extensions!==undefined?normalizeList(i.extensions,"extensions option"):[];this._immutable=i.immutable!==undefined?Boolean(i.immutable):false;this._index=i.index!==undefined?normalizeList(i.index,"index option"):["index.html"];this._lastModified=i.lastModified!==undefined?Boolean(i.lastModified):true;this._maxage=i.maxAge||i.maxage;this._maxage=typeof this._maxage==="string"?u(this._maxage):Number(this._maxage);this._maxage=!isNaN(this._maxage)?Math.min(Math.max(0,this._maxage),E):0;this._root=i.root?S(i.root):null;if(!this._root&&i.from){this.from(i.from)}}b.inherits(SendStream,h);SendStream.prototype.etag=r.function(function etag(a){this._etag=Boolean(a);n("etag %s",this._etag);return this},"send.etag: pass etag as option");SendStream.prototype.hidden=r.function(function hidden(a){this._hidden=Boolean(a);this._dotfiles=undefined;n("hidden %s",this._hidden);return this},"send.hidden: use dotfiles option");SendStream.prototype.index=r.function(function index(a){var index=!a?[]:normalizeList(a,"paths argument");n("index %o",a);this._index=index;return this},"send.index: pass index as option");SendStream.prototype.root=function root(a){this._root=S(String(a));n("root %s",this._root);return this};SendStream.prototype.from=r.function(SendStream.prototype.root,"send.from: pass root as option");SendStream.prototype.root=r.function(SendStream.prototype.root,"send.root: pass root as option");SendStream.prototype.maxage=r.function(function maxage(a){this._maxage=typeof a==="string"?u(a):Number(a);this._maxage=!isNaN(this._maxage)?Math.min(Math.max(0,this._maxage),E):0;n("max-age %d",this._maxage);return this},"send.maxage: pass maxAge as option");SendStream.prototype.error=function error(a,t){if(hasListeners(this,"error")){return this.emit("error",i(a,t,{expose:false}))}var e=this.res;var n=g[a]||String(a);var r=createHtmlDocument("Error",s(n));clearHeaders(e);if(t&&t.headers){setHeaders(e,t.headers)}e.statusCode=a;e.setHeader("Content-Type","text/html; charset=UTF-8");e.setHeader("Content-Length",Buffer.byteLength(r));e.setHeader("C