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

Function resolve

packages/react-error-overlay/fixtures/bundle.mjs:7955–7979  ·  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

7953 * @api private
7954 */
7955function resolve(relative, base) {
7956 var path = (base || '/').split('/').slice(0, -1).concat(relative.split('/'))
7957 , i = path.length
7958 , last = path[i - 1]
7959 , unshift = false
7960 , up = 0;
7961
7962 while (i--) {
7963 if (path[i] === '.') {
7964 path.splice(i, 1);
7965 } else if (path[i] === '..') {
7966 path.splice(i, 1);
7967 up++;
7968 } else if (up) {
7969 if (i === 0) unshift = true;
7970 path.splice(i, 1);
7971 up--;
7972 }
7973 }
7974
7975 if (unshift) path.unshift('');
7976 if (last === '.' || last === '..') path.push('');
7977
7978 return path.join('/');
7979}
7980
7981/**
7982 * The actual URL instance. Instead of returning an object we've opted-in to

Callers 15

hotDownloadManifestFunction · 0.70
URLFunction · 0.70
handleResolvedFunction · 0.70
doResolveFunction · 0.70
invokeFunction · 0.70
stepFunction · 0.70
bundle.mjsFile · 0.70
resFunction · 0.70
fileReaderReadyFunction · 0.70
choosePortFunction · 0.50
unmapper.jsFile · 0.50

Calls 4

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

Tested by

no test coverage detected