mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-25 00:49:15 +00:00
0.2.0 - Mid migration
This commit is contained in:
parent
139e6a915e
commit
7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions
77
web/node_modules/resolve-pathname/cjs/resolve-pathname.js
generated
vendored
Normal file
77
web/node_modules/resolve-pathname/cjs/resolve-pathname.js
generated
vendored
Normal file
|
@ -0,0 +1,77 @@
|
|||
'use strict';
|
||||
|
||||
function isAbsolute(pathname) {
|
||||
return pathname.charAt(0) === '/';
|
||||
}
|
||||
|
||||
// About 1.5x faster than the two-arg version of Array#splice()
|
||||
function spliceOne(list, index) {
|
||||
for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) {
|
||||
list[i] = list[k];
|
||||
}
|
||||
|
||||
list.pop();
|
||||
}
|
||||
|
||||
// This implementation is based heavily on node's url.parse
|
||||
function resolvePathname(to, from) {
|
||||
if (from === undefined) from = '';
|
||||
|
||||
var toParts = (to && to.split('/')) || [];
|
||||
var fromParts = (from && from.split('/')) || [];
|
||||
|
||||
var isToAbs = to && isAbsolute(to);
|
||||
var isFromAbs = from && isAbsolute(from);
|
||||
var mustEndAbs = isToAbs || isFromAbs;
|
||||
|
||||
if (to && isAbsolute(to)) {
|
||||
// to is absolute
|
||||
fromParts = toParts;
|
||||
} else if (toParts.length) {
|
||||
// to is relative, drop the filename
|
||||
fromParts.pop();
|
||||
fromParts = fromParts.concat(toParts);
|
||||
}
|
||||
|
||||
if (!fromParts.length) return '/';
|
||||
|
||||
var hasTrailingSlash;
|
||||
if (fromParts.length) {
|
||||
var last = fromParts[fromParts.length - 1];
|
||||
hasTrailingSlash = last === '.' || last === '..' || last === '';
|
||||
} else {
|
||||
hasTrailingSlash = false;
|
||||
}
|
||||
|
||||
var up = 0;
|
||||
for (var i = fromParts.length; i >= 0; i--) {
|
||||
var part = fromParts[i];
|
||||
|
||||
if (part === '.') {
|
||||
spliceOne(fromParts, i);
|
||||
} else if (part === '..') {
|
||||
spliceOne(fromParts, i);
|
||||
up++;
|
||||
} else if (up) {
|
||||
spliceOne(fromParts, i);
|
||||
up--;
|
||||
}
|
||||
}
|
||||
|
||||
if (!mustEndAbs) for (; up--; up) fromParts.unshift('..');
|
||||
|
||||
if (
|
||||
mustEndAbs &&
|
||||
fromParts[0] !== '' &&
|
||||
(!fromParts[0] || !isAbsolute(fromParts[0]))
|
||||
)
|
||||
fromParts.unshift('');
|
||||
|
||||
var result = fromParts.join('/');
|
||||
|
||||
if (hasTrailingSlash && result.substr(-1) !== '/') result += '/';
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
module.exports = resolvePathname;
|
1
web/node_modules/resolve-pathname/cjs/resolve-pathname.min.js
generated
vendored
Normal file
1
web/node_modules/resolve-pathname/cjs/resolve-pathname.min.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
"use strict";function isAbsolute(e){return"/"===e.charAt(0)}function spliceOne(e,t){for(var s=t,n=s+1,i=e.length;n<i;s+=1,n+=1)e[s]=e[n];e.pop()}function resolvePathname(e,t){void 0===t&&(t="");var s,n=e&&e.split("/")||[],i=t&&t.split("/")||[],l=e&&isAbsolute(e),r=t&&isAbsolute(t),o=l||r;if(e&&isAbsolute(e)?i=n:n.length&&(i.pop(),i=i.concat(n)),!i.length)return"/";if(i.length){var u=i[i.length-1];s="."===u||".."===u||""===u}else s=!1;for(var a=0,c=i.length;0<=c;c--){var f=i[c];"."===f?spliceOne(i,c):".."===f?(spliceOne(i,c),a++):a&&(spliceOne(i,c),a--)}if(!o)for(;a--;a)i.unshift("..");!o||""===i[0]||i[0]&&isAbsolute(i[0])||i.unshift("");var h=i.join("/");return s&&"/"!==h.substr(-1)&&(h+="/"),h}module.exports=resolvePathname;
|
Loading…
Add table
Add a link
Reference in a new issue