cdn-resolve
Version:
Resolves import paths to their CDN equivalents
19 lines (17 loc) • 456 B
JavaScript
import { t as parsePackage } from "./parse-s1dXDi-T.mjs";
//#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;
}
}
//#endregion
export { buildJSDelivrUrl as t };