pbu-local-url
Version:
seentao local url-parse
1 lines • 5.47 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["pbu-local-url"]=t():e["pbu-local-url"]=t()}(this,function(){return function(e){function t(r){if(o[r])return o[r].exports;var n=o[r]={exports:{},id:r,loaded:!1};return e[r].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var o={};return t.m=e,t.c=o,t.p="",t(0)}([function(e,t,o){"use strict";function r(e,t){function r(e){if(!e)return e;var t=/h_(\d+),w_(\d+)/;return t.test(e)?n(e,RegExp.$2,RegExp.$1):s(e)}function n(e,o,r){var n=e.indexOf("-public")!=-1?"pbu-public":"pbu-private";e=e.replace("pbu-public/","");var s=a(e,!0),u="/unsafe/"+o+"x"+r+"/"+n+s.pathname;return t.imgFixUrl+u}function s(e){var o=e.indexOf("-public")!=-1?"publicUrl":"privateUrl";e=e.replace("pbu-public/","");var r=a(e,!0);return t[o]+r.pathname}var a=o(1);return r(e)}e.exports=r},function(e,t,o){(function(t){"use strict";function r(e){return(e?e:"").toString().replace(m,"")}function n(e){var o;o="undefined"!=typeof window?window:"undefined"!=typeof t?t:"undefined"!=typeof self?self:{};var r=o.location||{};e=e||r;var n,s={},a=typeof e;if("blob:"===e.protocol)s=new u(unescape(e.pathname),{});else if("string"===a){s=new u(e,{});for(n in v)delete s[n]}else if("object"===a){for(n in e)n in v||(s[n]=e[n]);void 0===s.slashes&&(s.slashes=f.test(e.href))}return s}function s(e){e=r(e);var t=h.exec(e);return{protocol:t[1]?t[1].toLowerCase():"",slashes:!!t[2],rest:t[3]}}function a(e,t){if(""===e)return t;for(var o=(t||"/").split("/").slice(0,-1).concat(e.split("/")),r=o.length,n=o[r-1],s=!1,a=0;r--;)"."===o[r]?o.splice(r,1):".."===o[r]?(o.splice(r,1),a++):a&&(0===r&&(s=!0),o.splice(r,1),a--);return s&&o.unshift(""),"."!==n&&".."!==n||o.push(""),o.join("/")}function u(e,t,o){if(e=r(e),!(this instanceof u))return new u(e,t,o);var i,p,f,h,d,m,v=x.slice(),y=typeof t,b=this,g=0;for("object"!==y&&"string"!==y&&(o=t,t=null),o&&"function"!=typeof o&&(o=l.parse),t=n(t),p=s(e||""),i=!p.protocol&&!p.slashes,b.slashes=p.slashes||i&&t.slashes,b.protocol=p.protocol||t.protocol||"",e=p.rest,p.slashes||(v[3]=[/(.*)/,"pathname"]);g<v.length;g++)h=v[g],"function"!=typeof h?(f=h[0],m=h[1],f!==f?b[m]=e:"string"==typeof f?~(d=e.indexOf(f))&&("number"==typeof h[2]?(b[m]=e.slice(0,d),e=e.slice(d+h[2])):(b[m]=e.slice(d),e=e.slice(0,d))):(d=f.exec(e))&&(b[m]=d[1],e=e.slice(0,d.index)),b[m]=b[m]||(i&&h[3]?t[m]||"":""),h[4]&&(b[m]=b[m].toLowerCase())):e=h(e);o&&(b.query=o(b.query)),i&&t.slashes&&"/"!==b.pathname.charAt(0)&&(""!==b.pathname||""!==t.pathname)&&(b.pathname=a(b.pathname,t.pathname)),c(b.port,b.protocol)||(b.host=b.hostname,b.port=""),b.username=b.password="",b.auth&&(h=b.auth.split(":"),b.username=h[0]||"",b.password=h[1]||""),b.origin=b.protocol&&b.host&&"file:"!==b.protocol?b.protocol+"//"+b.host:"null",b.href=b.toString()}function i(e,t,o){var r=this;switch(e){case"query":"string"==typeof t&&t.length&&(t=(o||l.parse)(t)),r[e]=t;break;case"port":r[e]=t,c(t,r.protocol)?t&&(r.host=r.hostname+":"+t):(r.host=r.hostname,r[e]="");break;case"hostname":r[e]=t,r.port&&(t+=":"+r.port),r.host=t;break;case"host":r[e]=t,/:\d+$/.test(t)?(t=t.split(":"),r.port=t.pop(),r.hostname=t.join(":")):(r.hostname=t,r.port="");break;case"protocol":r.protocol=t.toLowerCase(),r.slashes=!o;break;case"pathname":case"hash":if(t){var n="pathname"===e?"/":"#";r[e]=t.charAt(0)!==n?n+t:t}else r[e]=t;break;default:r[e]=t}for(var s=0;s<x.length;s++){var a=x[s];a[4]&&(r[a[1]]=r[a[1]].toLowerCase())}return r.origin=r.protocol&&r.host&&"file:"!==r.protocol?r.protocol+"//"+r.host:"null",r.href=r.toString(),r}function p(e){e&&"function"==typeof e||(e=l.stringify);var t,o=this,r=o.protocol;r&&":"!==r.charAt(r.length-1)&&(r+=":");var n=r+(o.slashes?"//":"");return o.username&&(n+=o.username,o.password&&(n+=":"+o.password),n+="@"),n+=o.host+o.pathname,t="object"==typeof o.query?e(o.query):o.query,t&&(n+="?"!==t.charAt(0)?"?"+t:t),o.hash&&(n+=o.hash),n}var c=o(2),l=o(3),f=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,h=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\S\s]*)/i,d="[\\x09\\x0A\\x0B\\x0C\\x0D\\x20\\xA0\\u1680\\u180E\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000\\u2028\\u2029\\uFEFF]",m=new RegExp("^"+d+"+"),x=[["#","hash"],["?","query"],function(e){return e.replace("\\","/")},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d+)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],v={hash:1,query:1};u.prototype={set:i,toString:p},u.extractProtocol=s,u.location=n,u.trimLeft=r,u.qs=l,e.exports=u}).call(t,function(){return this}())},function(e,t){"use strict";e.exports=function(e,t){if(t=t.split(":")[0],e=+e,!e)return!1;switch(t){case"http":case"ws":return 80!==e;case"https":case"wss":return 443!==e;case"ftp":return 21!==e;case"gopher":return 70!==e;case"file":return!1}return 0!==e}},function(e,t){"use strict";function o(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function r(e){for(var t,r=/([^=?&]+)=?([^&]*)/g,n={};t=r.exec(e);){var s=o(t[1]),a=o(t[2]);null===s||null===a||s in n||(n[s]=a)}return n}function n(e,t){t=t||"";var o,r,n=[];"string"!=typeof t&&(t="?");for(r in e)if(a.call(e,r)){if(o=e[r],o||null!==o&&o!==s&&!isNaN(o)||(o=""),r=encodeURIComponent(r),o=encodeURIComponent(o),null===r||null===o)continue;n.push(r+"="+o)}return n.length?t+n.join("&"):""}var s,a=Object.prototype.hasOwnProperty;t.stringify=n,t.parse=r}])});