2 lines
796 B
JavaScript
2 lines
796 B
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.resolvePathname=e()}(this,function(){"use strict";function p(t){return"/"===t.charAt(0)}function d(t,e){for(var n=e,o=n+1,r=t.length;o<r;n+=1,o+=1)t[n]=t[o];t.pop()}return function(t,e){void 0===e&&(e="");var n,o=t&&t.split("/")||[],r=e&&e.split("/")||[],f=t&&p(t),i=e&&p(e),u=f||i;if(t&&p(t)?r=o:o.length&&(r.pop(),r=r.concat(o)),!r.length)return"/";if(r.length){var s=r[r.length-1];n="."===s||".."===s||""===s}else n=!1;for(var l=0,a=r.length;0<=a;a--){var c=r[a];"."===c?d(r,a):".."===c?(d(r,a),l++):l&&(d(r,a),l--)}if(!u)for(;l--;l)r.unshift("..");!u||""===r[0]||r[0]&&p(r[0])||r.unshift("");var h=r.join("/");return n&&"/"!==h.substr(-1)&&(h+="/"),h}});
|