MCPcopy
hub / github.com/react/create-react-app / resolve

Function resolve

packages/react-error-overlay/fixtures/bundle_u.mjs:8091–8115  ·  view source on GitHub ↗

* Resolve a relative URL pathname against a base URL pathname. * * @param {String} relative Pathname of the relative URL. * @param {String} base Pathname of the base URL. * @return {String} Resolved pathname. * @api private

(relative, base)

Source from the content-addressed store, hash-verified

8089 * @api private
8090 */
8091function resolve(relative, base) {
8092 var path = (base || '/').split('/').slice(0, -1).concat(relative.split('/'))
8093 , i = path.length
8094 , last = path[i - 1]
8095 , unshift = false
8096 , up = 0;
8097
8098 while (i--) {
8099 if (path[i] === '.') {
8100 path.splice(i, 1);
8101 } else if (path[i] === '..') {
8102 path.splice(i, 1);
8103 up++;
8104 } else if (up) {
8105 if (i === 0) unshift = true;
8106 path.splice(i, 1);
8107 up--;
8108 }
8109 }
8110
8111 if (unshift) path.unshift('');
8112 if (last === '.' || last === '..') path.push('');
8113
8114 return path.join('/');
8115}
8116
8117/**
8118 * The actual URL instance. Instead of returning an object we've opted-in to

Callers 9

hotDownloadManifestFunction · 0.70
URLFunction · 0.70
handleResolvedFunction · 0.70
doResolveFunction · 0.70
invokeFunction · 0.70
stepFunction · 0.70
bundle_u.mjsFile · 0.70
resFunction · 0.70
fileReaderReadyFunction · 0.70

Calls 4

rejectFunction · 0.70
getThenFunction · 0.70
finaleFunction · 0.70
doResolveFunction · 0.70

Tested by

no test coverage detected