@infuro/cms-core 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -751,14 +751,15 @@ function s3StoragePlugin(config) {
751
751
  // src/plugins/storage/local.ts
752
752
  function getLocalStorage(config) {
753
753
  const dir = (config.dir ?? "public/uploads").replace(/\/$/, "");
754
- const publicPath = config.publicPath ?? `/${dir.replace(/^\/+/, "").replace(/\\/g, "/")}`;
754
+ const publicPath = config.publicPath ?? (dir === "public/uploads" ? "/uploads" : `/${dir.replace(/^\/+/, "").replace(/\\/g, "/")}`);
755
755
  return {
756
756
  async upload(buffer, key, _contentType) {
757
757
  const fs = await import("fs/promises");
758
758
  const path = await import("path");
759
+ const normalizedKey = key.replace(/^\/+/, "").replace(/\.\./g, "");
760
+ const fileName = normalizedKey.replace(/^uploads\//, "");
759
761
  const fullDir = path.join(process.cwd(), dir);
760
762
  await fs.mkdir(fullDir, { recursive: true });
761
- const fileName = key.replace(/^\/+/, "").replace(/\.\./g, "");
762
763
  const filePath = path.join(fullDir, fileName);
763
764
  const fileDir = path.dirname(filePath);
764
765
  await fs.mkdir(fileDir, { recursive: true });