index.mjs 785 B

123456789101112131415161718192021222324252627
  1. // src/index.ts
  2. function src_default(pkgName, pkgVersion, opts) {
  3. let registry;
  4. if (opts == null ? void 0 : opts.registry) {
  5. registry = opts.registry.endsWith("/") ? opts.registry : `${opts.registry}/`;
  6. } else {
  7. registry = "https://registry.npmjs.org/";
  8. }
  9. const scopelessName = getScopelessName(pkgName);
  10. return `${registry}${pkgName}/-/${scopelessName}-${removeBuildMetadataFromVersion(pkgVersion)}.tgz`;
  11. }
  12. function removeBuildMetadataFromVersion(version) {
  13. const plusPos = version.indexOf("+");
  14. if (plusPos === -1)
  15. return version;
  16. return version.substring(0, plusPos);
  17. }
  18. function getScopelessName(name) {
  19. if (name[0] !== "@") {
  20. return name;
  21. }
  22. return name.split("/")[1];
  23. }
  24. export {
  25. src_default as default
  26. };
  27. //# sourceMappingURL=index.mjs.map