wirejs-scripts 3.0.10 → 3.0.12

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 (2) hide show
  1. package/bin.js +16 -5
  2. package/package.json +2 -2
package/bin.js CHANGED
@@ -210,6 +210,16 @@ function globMatch(pattern, text) {
210
210
  return regex.test(text);
211
211
  }
212
212
 
213
+ function toJSPath(path) {
214
+ if (path.endsWith('/')) {
215
+ return path + 'index.js';
216
+ } else if (!path.endsWith('.js')) {
217
+ return path + '.js';
218
+ } else {
219
+ return path;
220
+ }
221
+ }
222
+
213
223
  /**
214
224
  *
215
225
  * @param {Context} context
@@ -217,10 +227,11 @@ function globMatch(pattern, text) {
217
227
  */
218
228
  function routeSSR(context, forceExt) {
219
229
  const SSR_ROOT = path.join(CWD, 'dist', 'ssr');
220
- const asJSPath = forceExt ?
221
- context.location.pathname.replace(/\.(\w+)$/, `.${forceExt}`)
222
- : context.location.pathname
223
- ;
230
+
231
+ const asJSPath = forceExt
232
+ ? toJSPath(context.location.pathname)
233
+ : context.location.pathname;
234
+
224
235
  const allHandlers = fs.readdirSync(SSR_ROOT, { recursive: true })
225
236
  .filter(p => p.endsWith('.js'))
226
237
  .map(p => `/${p}`)
@@ -266,7 +277,7 @@ async function trySSRScriptPath(req, res) {
266
277
  async function trySSRPath(req, res) {
267
278
  const context = createContext(req);
268
279
 
269
- const asJSPath = context.location.pathname.replace(/\.(\w+)$/, '.js');
280
+ const asJSPath = context.location.pathname.replace(/\.(\w+)$/, '') + '.js';
270
281
  const srcPath = routeSSR(context, 'js');
271
282
  if (!srcPath) return false;
272
283
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wirejs-scripts",
3
- "version": "3.0.10",
3
+ "version": "3.0.12",
4
4
  "description": "Basic build and start commands for wirejs apps",
5
5
  "type": "module",
6
6
  "bin": {
@@ -34,6 +34,6 @@
34
34
  "style-loader": "^2.0.0",
35
35
  "webpack": "^5.97.1",
36
36
  "wirejs-dom": "^1.0.38",
37
- "wirejs-resources": "^0.1.12"
37
+ "wirejs-resources": "^0.1.14"
38
38
  }
39
39
  }