"use strict";
/* Socket Lib - Built with rolldown */
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_primordials_string = require('../../../primordials/string.js');

//#region src/eco/npm/npm/parse-git-url.ts
/**
* @file `parseGitUrl(resolved)` — extracts `{ url, commit }` from a `resolved`
*   field on an npm lockfile entry when it points to a git source (`git+…` or
*   `git://…`). Returns `undefined` when the resolved string is not a git URL.
*   When the URL has no `#<commit>` suffix, `commit` is `undefined`. Shape
*   matches socket-btm's smol-manifest internal `parseGitUrl` so smol-vs-JS
*   consumers see the same output.
*/
function parseGitUrl(resolved) {
	if (require_primordials_string.StringPrototypeIndexOf(resolved, "git+") !== 0 && require_primordials_string.StringPrototypeIndexOf(resolved, "git://") !== 0) return;
	const hashIndex = require_primordials_string.StringPrototypeIndexOf(resolved, "#");
	if (hashIndex === -1) return {
		url: resolved,
		commit: void 0
	};
	return {
		url: require_primordials_string.StringPrototypeSlice(resolved, 0, hashIndex),
		commit: require_primordials_string.StringPrototypeSlice(resolved, hashIndex + 1)
	};
}

//#endregion
exports.parseGitUrl = parseGitUrl;