@adminforth/upload 2.14.5 → 2.15.0

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.
Files changed (3) hide show
  1. package/dist/index.js +18 -0
  2. package/index.ts +16 -0
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -134,6 +134,24 @@ export default class UploadPlugin extends AdminForthPlugin {
134
134
  });
135
135
  }
136
136
  ;
137
+ isInternalUrl(url) {
138
+ return __awaiter(this, void 0, void 0, function* () {
139
+ const adapter = this.options.storageAdapter;
140
+ if (adapter && typeof adapter.isInternalUrl === 'function') {
141
+ try {
142
+ return yield adapter.isInternalUrl(url);
143
+ }
144
+ catch (err) {
145
+ console.error(`[UploadPlugin] Error calling isInternalUrl on adapter:`, err);
146
+ return false;
147
+ }
148
+ }
149
+ else {
150
+ throw new Error('Plese update storage adapter');
151
+ }
152
+ return false;
153
+ });
154
+ }
137
155
  instanceUniqueRepresentation(pluginOptions) {
138
156
  return `${pluginOptions.pathColumnName}`;
139
157
  }
package/index.ts CHANGED
@@ -162,6 +162,22 @@ export default class UploadPlugin extends AdminForthPlugin {
162
162
  return { ok: true };
163
163
  };
164
164
 
165
+ async isInternalUrl(url: string): Promise<boolean> {
166
+ const adapter = this.options.storageAdapter as any;
167
+
168
+ if (adapter && typeof adapter.isInternalUrl === 'function') {
169
+ try {
170
+ return await adapter.isInternalUrl(url);
171
+ } catch (err) {
172
+ console.error(`[UploadPlugin] Error calling isInternalUrl on adapter:`, err);
173
+ return false;
174
+ }
175
+ } else {
176
+ throw new Error ('Plese update storage adapter')
177
+ }
178
+ return false;
179
+ }
180
+
165
181
  instanceUniqueRepresentation(pluginOptions: any) : string {
166
182
  return `${pluginOptions.pathColumnName}`;
167
183
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/upload",
3
- "version": "2.14.5",
3
+ "version": "2.15.0",
4
4
  "description": "Plugin for uploading files for adminforth",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",