total5 0.0.14-2 → 0.0.14-4

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/changelog.txt CHANGED
@@ -11,6 +11,8 @@
11
11
  - disabled auto-cleaning files in FlowStream workers
12
12
  - improved loading static files in release mode
13
13
  - added support for `HEAD` method
14
+ - fixed file routing
15
+ - added support for handling specific file extensions in the form `ROUTE('FILE *.php', ...)`
14
16
 
15
17
  ========================
16
18
  0.0.13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "total5",
3
- "version": "0.0.14-2",
3
+ "version": "0.0.14-4",
4
4
  "description": "Total.js framework v5",
5
5
  "main": "index.js",
6
6
  "directories": {
package/routing.js CHANGED
@@ -130,8 +130,13 @@ function Route(url, action, size) {
130
130
 
131
131
  let types = t.url[t.url.length - 1];
132
132
 
133
- // fixed filename
134
- if (t.url2.indexOf('*') === -1) {
133
+ if (t.url2[0] !== '/' && !t.url2.includes('/')) {
134
+ // all extensions
135
+ t.all = true;
136
+ }
137
+
138
+ if (!t.url2.includes('*')) {
139
+ // fixed filename
135
140
  t.fixed = true;
136
141
  } else if (types === '*') {
137
142
  t.url[t.url.length - 1] = '*';
@@ -443,6 +448,11 @@ exports.sort = function() {
443
448
 
444
449
  for (let route of F.routes.files) {
445
450
 
451
+ if (route.all) {
452
+ for (let ext in route.ext)
453
+ cache['.' + ext] = route;
454
+ }
455
+
446
456
  if (route.fixed) {
447
457
  cache[route.url2] = route;
448
458
  continue;
@@ -680,15 +690,23 @@ exports.lookupcors = function(ctrl) {
680
690
  exports.lookupfile = function(ctrl, auth = 0) {
681
691
  if (F.routes.files.length) {
682
692
 
683
- // fixed
693
+ // fixed name
684
694
  let route = F.routes.filescache[ctrl.url];
685
695
  if (route)
686
696
  return route;
687
697
 
698
+ // fixed extension
699
+ route = F.routes.filescache['.' + ctrl.extension];
700
+ if (route)
701
+ return route;
702
+
688
703
  let key = '';
689
704
  for (let i = 0; i < ctrl.split2.length - 1; i++)
690
705
  key += (i ? '/' : '') + ctrl.split2[i];
691
706
 
707
+ if (!key)
708
+ key = '/';
709
+
692
710
  let routes = F.routes.filescache[key];
693
711
  if (routes)
694
712
  return compareflags(ctrl, routes, auth);