rtjscomp 0.9.0 → 0.9.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/rtjscomp.js +14 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rtjscomp",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "php-like server but with javascript",
5
5
  "repository": {
6
6
  "type": "git",
package/rtjscomp.js CHANGED
@@ -528,8 +528,12 @@ const request_handle = async (request, response, https) => {
528
528
  path.includes('//')
529
529
  ) throw 404;
530
530
  if (path.length > 1 && path.endsWith('/')) {
531
- response.setHeader('Location', path.slice(0, -1));
532
- throw 301;
531
+ path = path.slice(0, -1);
532
+ // is file with extension?
533
+ if (path.lastIndexOf('/') < path.lastIndexOf('.')) {
534
+ response.setHeader('Location', path);
535
+ throw 301;
536
+ }
533
537
  }
534
538
  path = path.slice(1);
535
539
 
@@ -1107,7 +1111,7 @@ await file_keep_new(PATH_CONFIG + 'init.js', async data => {
1107
1111
 
1108
1112
  await fsp.writeFile(
1109
1113
  'rtjscomp.json',
1110
- JSON.stringify(json, null, 2),
1114
+ JSON.stringify(json, null, '\t') + '\n',
1111
1115
  'utf8'
1112
1116
  );
1113
1117
  log('[deprecated] config files found, rtjscomp.json written, please delete config files');
@@ -1282,7 +1286,13 @@ await file_keep_new('rtjscomp.json', data => {
1282
1286
  }
1283
1287
  else {
1284
1288
  path_aliases.set(key, value);
1285
- path_aliases_reverse.set(value, '/' + key);
1289
+ const existing = path_aliases_reverse.get(value);
1290
+ if (
1291
+ existing == null ||
1292
+ existing.length - 1 > value.length
1293
+ ) {
1294
+ path_aliases_reverse.set(value, '/' + key);
1295
+ }
1286
1296
  }
1287
1297
  }
1288
1298
  }