Files
klz-cables.com/.pnpm-store/v10/files/cc/f28767fa698a78bfa39b5736fa63e259b925af21f1b181239a0707338c60560a73eb4f00a429fd202041f8338683c2945d6ec256c7ca2190fb632a4dd81e39
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

29 lines
1.1 KiB
Plaintext

import { formatAdminURL } from '../utilities/formatAdminURL.js';
/**
* Generates a file path or URL based on the provided parameters.
*
* If urlOrPath is an external URL, it returns it as is.
* If a filename is provided, it constructs a URL using the collection slug and API route.
* If neither condition is met, it returns null.
*
* If you set relative to true, the returned URL will be relative to the serverURL (unless external).
*/ export function generateFilePathOrURL({ collectionSlug, config, filename, relative, serverURL, urlOrPath }) {
if (urlOrPath) {
if (!urlOrPath.startsWith('/') && !urlOrPath.startsWith(serverURL || '')) {
// external url
return urlOrPath;
}
}
if (filename) {
// local file url
return formatAdminURL({
apiRoute: config.routes?.api || '',
path: `/${collectionSlug}/file/${encodeURIComponent(filename)}`,
relative,
serverURL: config.serverURL
});
}
return null;
}
//# sourceMappingURL=generateFilePathOrURL.js.map