@mulmoclaude/core 7.8.1 → 7.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -585,8 +585,14 @@ function parseGithub(rest) {
|
|
|
585
585
|
const ownerRepo = hash === -1 ? rest : rest.slice(0, hash);
|
|
586
586
|
const tag = hash === -1 ? null : rest.slice(hash + 1);
|
|
587
587
|
const [owner = "", repo = "", ...extra] = ownerRepo.split("/");
|
|
588
|
-
if (extra.length > 0
|
|
589
|
-
|
|
588
|
+
if (extra.length > 0) return refuse$1(`not a GitHub owner/repo: ${JSON.stringify(ownerRepo)}`);
|
|
589
|
+
return githubSource(owner, repo, tag, ownerRepo);
|
|
590
|
+
}
|
|
591
|
+
/** Owner, repo and tag already split apart, checked as one GitHub source. `shown` is how the owner/repo
|
|
592
|
+
* was written, for the error. */
|
|
593
|
+
function githubSource(owner, repo, tag, shown) {
|
|
594
|
+
if (!GITHUB_OWNER.test(owner)) return refuse$1(`not a GitHub owner/repo: ${JSON.stringify(shown)}`);
|
|
595
|
+
if (!GITHUB_REPO.test(repo) || repo === "." || repo === "..") return refuse$1(`not a GitHub owner/repo: ${JSON.stringify(shown)}`);
|
|
590
596
|
if (tag !== null && !isGithubTag(tag)) return refuse$1(`not a release tag: ${JSON.stringify(tag)}`);
|
|
591
597
|
return {
|
|
592
598
|
ok: true,
|
|
@@ -611,12 +617,50 @@ function parseFile(rest) {
|
|
|
611
617
|
}
|
|
612
618
|
};
|
|
613
619
|
}
|
|
620
|
+
var GITHUB_HOSTS = /* @__PURE__ */ new Set(["github.com", "www.github.com"]);
|
|
621
|
+
var URL_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*:\/\//;
|
|
622
|
+
var GIT_SUFFIX = /\.git$/;
|
|
623
|
+
var GITHUB_URL_SHAPES = "https://github.com/<owner>/<repo>, …/releases/latest or …/releases/tag/<tag>";
|
|
624
|
+
var AUTHORITY_WITH_USERINFO = /^[A-Za-z][A-Za-z0-9+.-]*:\/\/[^/?#\\]*@/;
|
|
625
|
+
var refuseUrl = (input) => refuse$1(`not a GitHub repository or release URL (${GITHUB_URL_SHAPES}): ${JSON.stringify(input)}`);
|
|
626
|
+
/** The tag a release path names: none for the repository itself or `releases/latest`, else `releases/tag/<tag>`.
|
|
627
|
+
* `undefined` when the path is something else (a branch, a file, an issue). */
|
|
628
|
+
function releaseTagOf(rest) {
|
|
629
|
+
if (rest.length === 0) return null;
|
|
630
|
+
if (rest.length === 2 && rest[0] === "releases" && rest[1] === "latest") return null;
|
|
631
|
+
if (rest.length >= 3 && rest[0] === "releases" && rest[1] === "tag") return rest.slice(2).join("/");
|
|
632
|
+
}
|
|
633
|
+
/** A URL path's segments, percent-decoded; `null` when one does not decode. Only the leading `/` and one
|
|
634
|
+
* trailing `/` are dropped: an empty segment anywhere else is kept, so a tag written `x//y` is refused as
|
|
635
|
+
* `github:` refuses it rather than read as `x/y`. */
|
|
636
|
+
function decodedSegments(pathname) {
|
|
637
|
+
const segments = pathname.split("/").slice(1);
|
|
638
|
+
const withoutTrailing = segments.at(-1) === "" ? segments.slice(0, -1) : segments;
|
|
639
|
+
try {
|
|
640
|
+
return withoutTrailing.map((segment) => decodeURIComponent(segment));
|
|
641
|
+
} catch {
|
|
642
|
+
return null;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
function parseGithubUrl(input) {
|
|
646
|
+
const url = URL.canParse(input) ? new URL(input) : null;
|
|
647
|
+
if (url === null || url.protocol !== "https:" || !GITHUB_HOSTS.has(url.hostname)) return refuseUrl(input);
|
|
648
|
+
if (url.port !== "" || AUTHORITY_WITH_USERINFO.test(input)) return refuseUrl(input);
|
|
649
|
+
const segments = decodedSegments(url.pathname);
|
|
650
|
+
if (segments === null) return refuseUrl(input);
|
|
651
|
+
const [owner = "", repo = "", ...rest] = segments;
|
|
652
|
+
const tag = releaseTagOf(rest);
|
|
653
|
+
if (tag === void 0 || owner === "" || repo === "") return refuseUrl(input);
|
|
654
|
+
const bareRepo = repo.replace(GIT_SUFFIX, "");
|
|
655
|
+
return githubSource(owner, bareRepo, tag, `${owner}/${bareRepo}`);
|
|
656
|
+
}
|
|
614
657
|
function parseInstallSource(input) {
|
|
615
658
|
if (typeof input !== "string") return refuse$1("an install source is a string");
|
|
616
659
|
const trimmed = input.trim();
|
|
617
660
|
if (trimmed === "") return refuse$1("an install source is empty");
|
|
618
661
|
if (trimmed.startsWith(GITHUB_PREFIX)) return parseGithub(trimmed.slice(7));
|
|
619
662
|
if (trimmed.startsWith(FILE_PREFIX)) return parseFile(trimmed.slice(5));
|
|
663
|
+
if (URL_SCHEME.test(trimmed)) return parseGithubUrl(trimmed);
|
|
620
664
|
return parseNpm(trimmed);
|
|
621
665
|
}
|
|
622
666
|
/** The ledger's `source` field for what was actually installed: the resolved version or tag. */
|