"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.depPathToRef = void 0;
const dependency_path_1 = require("dependency-path");
const encodeRegistry = require("encode-registry");
function depPathToRef(depPath, opts) {
    if (opts.resolution.type)
        return depPath;
    const registryName = encodeRegistry(dependency_path_1.getRegistryByPackageName(opts.registries, opts.realName));
    if (depPath.startsWith(`${registryName}/`)) {
        depPath = depPath.replace(`${registryName}/`, '/');
    }
    if (depPath[0] === '/' && opts.alias === opts.realName) {
        const ref = depPath.replace(`/${opts.realName}/`, '');
        if (!ref.includes('/'))
            return ref;
    }
    return depPath;
}
exports.depPathToRef = depPathToRef;
//# sourceMappingURL=lockfile.js.map