@adminforth/upload 2.15.0 → 2.15.1

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
@@ -136,9 +136,17 @@ export default class UploadPlugin extends AdminForthPlugin {
136
136
  ;
137
137
  isInternalUrl(url) {
138
138
  return __awaiter(this, void 0, void 0, function* () {
139
+ var _a;
139
140
  const adapter = this.options.storageAdapter;
140
141
  if (adapter && typeof adapter.isInternalUrl === 'function') {
141
142
  try {
143
+ if ((_a = this.options.preview) === null || _a === void 0 ? void 0 : _a.previewUrl) {
144
+ const previewUrl = this.options.preview.previewUrl({ filePath: 'test_filepath' });
145
+ if (url.startsWith(previewUrl.replace('test_filepath', ''))) {
146
+ return true;
147
+ }
148
+ return false;
149
+ }
142
150
  return yield adapter.isInternalUrl(url);
143
151
  }
144
152
  catch (err) {
package/index.ts CHANGED
@@ -164,9 +164,15 @@ export default class UploadPlugin extends AdminForthPlugin {
164
164
 
165
165
  async isInternalUrl(url: string): Promise<boolean> {
166
166
  const adapter = this.options.storageAdapter as any;
167
-
168
167
  if (adapter && typeof adapter.isInternalUrl === 'function') {
169
168
  try {
169
+ if(this.options.preview?.previewUrl) {
170
+ const previewUrl = this.options.preview.previewUrl({ filePath: 'test_filepath' });
171
+ if (url.startsWith(previewUrl.replace('test_filepath', ''))) {
172
+ return true;
173
+ }
174
+ return false;
175
+ }
170
176
  return await adapter.isInternalUrl(url);
171
177
  } catch (err) {
172
178
  console.error(`[UploadPlugin] Error calling isInternalUrl on adapter:`, err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/upload",
3
- "version": "2.15.0",
3
+ "version": "2.15.1",
4
4
  "description": "Plugin for uploading files for adminforth",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",