MCPcopy
hub / github.com/vercel/hyper / explodeHostedGitFragment

Function explodeHostedGitFragment

bin/yarn-standalone.js:35672–35697  ·  view source on GitHub ↗
(fragment, reporter)

Source from the content-addressed store, hash-verified

35670}
35671
35672function explodeHostedGitFragment(fragment, reporter) {
35673 const hash = parseHash(fragment);
35674
35675 const preParts = fragment.split('@');
35676 if (preParts.length > 2) {
35677 fragment = preParts[1] + '@' + preParts[2];
35678 }
35679
35680 const parts = fragment.replace(/(.*?)#.*/, '$1') // Strip hash
35681 .replace(/.*:(.*)/, '$1') // Strip prefixed protocols
35682 .replace(/.git$/, '') // Strip the .git suffix
35683 .split('/');
35684
35685 const user = parts[parts.length - 2];
35686 const repo = parts[parts.length - 1];
35687
35688 if (user === undefined || repo === undefined) {
35689 throw new (_errors || _load_errors()).MessageError(reporter.lang('invalidHostedGitFragment', fragment));
35690 }
35691
35692 return {
35693 user,
35694 repo,
35695 hash
35696 };
35697}
35698
35699class HostedGitResolver extends (_exoticResolver || _load_exoticResolver()).default {
35700 constructor(request, fragment) {

Callers 1

constructorMethod · 0.85

Calls 3

parseHashFunction · 0.85
_load_errorsFunction · 0.85
langMethod · 0.45

Tested by

no test coverage detected