cdn-resolve
Version:
Resolves import paths to their CDN equivalents
19 lines (17 loc) • 452 B
JavaScript
import { parsePackage } from "./parse-DfZc17eY.js";
//#region src/jsdelivr.ts
/**
* Builds a JSDelivr URL for the specified module.
* @param {string} module - The name of the module.
* @returns {URL} The JSDelivr URL for the module.
*/
function buildJSDelivrUrl(module) {
try {
const pkg = parsePackage(module);
return new URL(pkg.full, "https://cdn.jsdelivr.net/npm/");
} catch {
return void 0;
}
}
//#endregion
export { buildJSDelivrUrl };