@payloadcms/plugin-cloud-storage 3.80.0-internal.60d6f94 → 3.80.0-internal.82dcece

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.
@@ -1 +1 @@
1
- {"version":3,"file":"getFilePrefix.d.ts","sourceRoot":"","sources":["../../src/utilities/getFilePrefix.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAgB,MAAM,SAAS,CAAA;AAE7E,wBAAsB,aAAa,CAAC,EAClC,mBAAmB,EACnB,UAAU,EACV,QAAQ,EACR,GAAG,GACJ,EAAE;IACD,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,UAAU,EAAE,gBAAgB,CAAA;IAC5B,QAAQ,EAAE,MAAM,CAAA;IAChB,GAAG,EAAE,cAAc,CAAA;CACpB,GAAG,OAAO,CAAC,MAAM,CAAC,CAgClB"}
1
+ {"version":3,"file":"getFilePrefix.d.ts","sourceRoot":"","sources":["../../src/utilities/getFilePrefix.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAgB,MAAM,SAAS,CAAA;AAkB7E,wBAAsB,aAAa,CAAC,EAClC,mBAAmB,EACnB,UAAU,EACV,QAAQ,EACR,GAAG,GACJ,EAAE;IACD,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,UAAU,EAAE,gBAAgB,CAAA;IAC5B,QAAQ,EAAE,MAAM,CAAA;IAChB,GAAG,EAAE,cAAc,CAAA;CACpB,GAAG,OAAO,CAAC,MAAM,CAAC,CAgClB"}
@@ -1,7 +1,13 @@
1
+ /**
2
+ * Normalizes a storage prefix to ensure only valid path segments are included.
3
+ */ function sanitizePrefix(prefix) {
4
+ return prefix.replace(/\\/g, '/').split('/').filter((segment)=>segment !== '..' && segment !== '.').join('/').replace(/^\/+/, '')// eslint-disable-next-line no-control-regex
5
+ .replace(/[\x00-\x1f\x80-\x9f]/g, '');
6
+ }
1
7
  export async function getFilePrefix({ clientUploadContext, collection, filename, req }) {
2
8
  // Prioritize from clientUploadContext if there is:
3
9
  if (clientUploadContext && typeof clientUploadContext === 'object' && 'prefix' in clientUploadContext && typeof clientUploadContext.prefix === 'string') {
4
- return clientUploadContext.prefix;
10
+ return sanitizePrefix(clientUploadContext.prefix);
5
11
  }
6
12
  const imageSizes = collection?.upload?.imageSizes || [];
7
13
  const files = await req.payload.find({
@@ -26,7 +32,7 @@ export async function getFilePrefix({ clientUploadContext, collection, filename,
26
32
  }
27
33
  });
28
34
  const prefix = files?.docs?.[0]?.prefix;
29
- return prefix ? prefix : '';
35
+ return prefix ? sanitizePrefix(prefix) : '';
30
36
  }
31
37
 
32
38
  //# sourceMappingURL=getFilePrefix.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/getFilePrefix.ts"],"sourcesContent":["import type { CollectionConfig, PayloadRequest, UploadConfig } from 'payload'\n\nexport async function getFilePrefix({\n clientUploadContext,\n collection,\n filename,\n req,\n}: {\n clientUploadContext?: unknown\n collection: CollectionConfig\n filename: string\n req: PayloadRequest\n}): Promise<string> {\n // Prioritize from clientUploadContext if there is:\n if (\n clientUploadContext &&\n typeof clientUploadContext === 'object' &&\n 'prefix' in clientUploadContext &&\n typeof clientUploadContext.prefix === 'string'\n ) {\n return clientUploadContext.prefix\n }\n\n const imageSizes = (collection?.upload as UploadConfig)?.imageSizes || []\n\n const files = await req.payload.find({\n collection: collection.slug,\n depth: 0,\n draft: true,\n limit: 1,\n pagination: false,\n where: {\n or: [\n {\n filename: { equals: filename },\n },\n ...imageSizes.map((imageSize) => ({\n [`sizes.${imageSize.name}.filename`]: { equals: filename },\n })),\n ],\n },\n })\n const prefix = files?.docs?.[0]?.prefix\n return prefix ? (prefix as string) : ''\n}\n"],"names":["getFilePrefix","clientUploadContext","collection","filename","req","prefix","imageSizes","upload","files","payload","find","slug","depth","draft","limit","pagination","where","or","equals","map","imageSize","name","docs"],"mappings":"AAEA,OAAO,eAAeA,cAAc,EAClCC,mBAAmB,EACnBC,UAAU,EACVC,QAAQ,EACRC,GAAG,EAMJ;IACC,mDAAmD;IACnD,IACEH,uBACA,OAAOA,wBAAwB,YAC/B,YAAYA,uBACZ,OAAOA,oBAAoBI,MAAM,KAAK,UACtC;QACA,OAAOJ,oBAAoBI,MAAM;IACnC;IAEA,MAAMC,aAAa,AAACJ,YAAYK,QAAyBD,cAAc,EAAE;IAEzE,MAAME,QAAQ,MAAMJ,IAAIK,OAAO,CAACC,IAAI,CAAC;QACnCR,YAAYA,WAAWS,IAAI;QAC3BC,OAAO;QACPC,OAAO;QACPC,OAAO;QACPC,YAAY;QACZC,OAAO;YACLC,IAAI;gBACF;oBACEd,UAAU;wBAAEe,QAAQf;oBAAS;gBAC/B;mBACGG,WAAWa,GAAG,CAAC,CAACC,YAAe,CAAA;wBAChC,CAAC,CAAC,MAAM,EAAEA,UAAUC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE;4BAAEH,QAAQf;wBAAS;oBAC3D,CAAA;aACD;QACH;IACF;IACA,MAAME,SAASG,OAAOc,MAAM,CAAC,EAAE,EAAEjB;IACjC,OAAOA,SAAUA,SAAoB;AACvC"}
1
+ {"version":3,"sources":["../../src/utilities/getFilePrefix.ts"],"sourcesContent":["import type { CollectionConfig, PayloadRequest, UploadConfig } from 'payload'\n\n/**\n * Normalizes a storage prefix to ensure only valid path segments are included.\n */\nfunction sanitizePrefix(prefix: string): string {\n return (\n prefix\n .replace(/\\\\/g, '/')\n .split('/')\n .filter((segment) => segment !== '..' && segment !== '.')\n .join('/')\n .replace(/^\\/+/, '')\n // eslint-disable-next-line no-control-regex\n .replace(/[\\x00-\\x1f\\x80-\\x9f]/g, '')\n )\n}\n\nexport async function getFilePrefix({\n clientUploadContext,\n collection,\n filename,\n req,\n}: {\n clientUploadContext?: unknown\n collection: CollectionConfig\n filename: string\n req: PayloadRequest\n}): Promise<string> {\n // Prioritize from clientUploadContext if there is:\n if (\n clientUploadContext &&\n typeof clientUploadContext === 'object' &&\n 'prefix' in clientUploadContext &&\n typeof clientUploadContext.prefix === 'string'\n ) {\n return sanitizePrefix(clientUploadContext.prefix)\n }\n\n const imageSizes = (collection?.upload as UploadConfig)?.imageSizes || []\n\n const files = await req.payload.find({\n collection: collection.slug,\n depth: 0,\n draft: true,\n limit: 1,\n pagination: false,\n where: {\n or: [\n {\n filename: { equals: filename },\n },\n ...imageSizes.map((imageSize) => ({\n [`sizes.${imageSize.name}.filename`]: { equals: filename },\n })),\n ],\n },\n })\n const prefix = files?.docs?.[0]?.prefix\n return prefix ? sanitizePrefix(prefix as string) : ''\n}\n"],"names":["sanitizePrefix","prefix","replace","split","filter","segment","join","getFilePrefix","clientUploadContext","collection","filename","req","imageSizes","upload","files","payload","find","slug","depth","draft","limit","pagination","where","or","equals","map","imageSize","name","docs"],"mappings":"AAEA;;CAEC,GACD,SAASA,eAAeC,MAAc;IACpC,OACEA,OACGC,OAAO,CAAC,OAAO,KACfC,KAAK,CAAC,KACNC,MAAM,CAAC,CAACC,UAAYA,YAAY,QAAQA,YAAY,KACpDC,IAAI,CAAC,KACLJ,OAAO,CAAC,QAAQ,GACjB,4CAA4C;KAC3CA,OAAO,CAAC,yBAAyB;AAExC;AAEA,OAAO,eAAeK,cAAc,EAClCC,mBAAmB,EACnBC,UAAU,EACVC,QAAQ,EACRC,GAAG,EAMJ;IACC,mDAAmD;IACnD,IACEH,uBACA,OAAOA,wBAAwB,YAC/B,YAAYA,uBACZ,OAAOA,oBAAoBP,MAAM,KAAK,UACtC;QACA,OAAOD,eAAeQ,oBAAoBP,MAAM;IAClD;IAEA,MAAMW,aAAa,AAACH,YAAYI,QAAyBD,cAAc,EAAE;IAEzE,MAAME,QAAQ,MAAMH,IAAII,OAAO,CAACC,IAAI,CAAC;QACnCP,YAAYA,WAAWQ,IAAI;QAC3BC,OAAO;QACPC,OAAO;QACPC,OAAO;QACPC,YAAY;QACZC,OAAO;YACLC,IAAI;gBACF;oBACEb,UAAU;wBAAEc,QAAQd;oBAAS;gBAC/B;mBACGE,WAAWa,GAAG,CAAC,CAACC,YAAe,CAAA;wBAChC,CAAC,CAAC,MAAM,EAAEA,UAAUC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE;4BAAEH,QAAQd;wBAAS;oBAC3D,CAAA;aACD;QACH;IACF;IACA,MAAMT,SAASa,OAAOc,MAAM,CAAC,EAAE,EAAE3B;IACjC,OAAOA,SAASD,eAAeC,UAAoB;AACrD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/plugin-cloud-storage",
3
- "version": "3.80.0-internal.60d6f94",
3
+ "version": "3.80.0-internal.82dcece",
4
4
  "description": "The official cloud storage plugin for Payload CMS",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -51,18 +51,18 @@
51
51
  "dependencies": {
52
52
  "find-node-modules": "^2.1.3",
53
53
  "range-parser": "^1.2.1",
54
- "@payloadcms/ui": "3.80.0-internal.60d6f94"
54
+ "@payloadcms/ui": "3.80.0-internal.82dcece"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@types/find-node-modules": "^2.1.2",
58
58
  "@types/react": "19.2.9",
59
59
  "@types/react-dom": "19.2.3",
60
- "payload": "3.80.0-internal.60d6f94"
60
+ "payload": "3.80.0-internal.82dcece"
61
61
  },
62
62
  "peerDependencies": {
63
63
  "react": "^19.0.1 || ^19.1.2 || ^19.2.1",
64
64
  "react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1",
65
- "payload": "3.80.0-internal.60d6f94"
65
+ "payload": "3.80.0-internal.82dcece"
66
66
  },
67
67
  "publishConfig": {
68
68
  "registry": "https://registry.npmjs.org/"