vona-module-a-static 5.0.23 → 5.0.25

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
@@ -118,7 +118,11 @@ async function _getFullPathInner(ctx, dir, filename, options) {
118
118
  // trim prefix
119
119
  if (options.apiStaticPrefix !== '/') {
120
120
  const filePrefix = path.normalize(options.apiStaticPrefix.replace(/^\//, ''));
121
- if (filename.indexOf(filePrefix) !== 0) throw new Error(`invalid filename: ${filename}`);
121
+ if (filename.indexOf(filePrefix) !== 0) {
122
+ return;
123
+ // cannot throw error
124
+ // throw new Error(`invalid filename: ${filename}`);
125
+ }
122
126
  filename = filename.slice(filePrefix.length);
123
127
  }
124
128
  // check
@@ -134,7 +138,11 @@ async function _getFullPathInner(ctx, dir, filename, options) {
134
138
  // static
135
139
  const moduleRelativeName = `${wordFirst}-${parts.shift()}`;
136
140
  const module = ctx.app.meta.modules[moduleRelativeName];
137
- if (!module) throw new Error(`invalid filename: ${filename}`);
141
+ if (!module) {
142
+ return;
143
+ // cannot throw error
144
+ // throw new Error(`invalid filename: ${filename}`);
145
+ }
138
146
  const fullPath = ctx.app.util.getAssetPathPhysical(moduleRelativeName, 'static', parts.join(path.sep));
139
147
  return fullPath;
140
148
  }
@@ -161,6 +169,10 @@ class BeanStaticBase extends BeanBase {
161
169
  get(path) {
162
170
  return this.app.util.combineStaticPath(path, this[SymbolModuleBelong]);
163
171
  }
172
+ getURL(path) {
173
+ const path2 = this.get(path);
174
+ return this.app.util.getAbsoluteUrl(path2);
175
+ }
164
176
  }
165
177
 
166
178
  export { BeanAssetBase, BeanStaticBase, EventResolvePath, MiddlewareSystemStatic, ScopeModuleAStatic, SymbolStaticGetFullPathInner };
@@ -1,4 +1,5 @@
1
1
  import { BeanBase } from 'vona';
2
2
  export declare class BeanStaticBase<TypeStaticGetPath> extends BeanBase {
3
3
  get(path: TypeStaticGetPath): string;
4
+ getURL(path: TypeStaticGetPath): string;
4
5
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-module-a-static",
3
3
  "type": "module",
4
- "version": "5.0.23",
4
+ "version": "5.0.25",
5
5
  "title": "a-static",
6
6
  "vonaModule": {
7
7
  "dependencies": {},