@lobehub/ui
Version:
Lobe UI is an open-source UI component library for building AIGC web apps
42 lines (41 loc) • 1.14 kB
JavaScript
import urlJoin from 'url-join';
var UNPKG_API = 'https://unpkg.com';
var ALIYUN_API = 'https://registry.npmmirror.com';
export var genCdnUrl = function genCdnUrl(_ref) {
var pkg = _ref.pkg,
_ref$version = _ref.version,
version = _ref$version === void 0 ? 'latest' : _ref$version,
path = _ref.path,
proxy = _ref.proxy;
switch (proxy) {
case 'unpkg':
{
return urlJoin(UNPKG_API, "".concat(pkg, "@").concat(version), path);
}
default:
{
return urlJoin(ALIYUN_API, pkg, version, 'files', path);
}
}
};
// export type JsdelivrCDN = 'jsdelivr' | 'lobehub';
//
// const JSDELIVR_API = 'https://fastly.jsdelivr.net';
// const LOBEHUB_API = 'https://jsdelivr.lobeobjects.space';
//
// export interface JsdelivrApi {
// path: string;
// proxy?: JsdelivrCDN;
// repo: string;
// }
//
// export const genJsdelivrUrl = ({ path, proxy, repo }: JsdelivrApi): string => {
// switch (proxy) {
// case 'jsdelivr': {
// return urlJoin(JSDELIVR_API, 'gh', repo, path);
// }
// default: {
// return urlJoin(LOBEHUB_API, 'gh', repo, path);
// }
// }
// };