koa-classic-server 3.0.1 → 3.1.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 (106) hide show
  1. package/README.md +44 -120
  2. package/index.cjs +200 -21
  3. package/package.json +10 -5
  4. package/.github/workflows/npm-publish.yml +0 -98
  5. package/CLAUDE.md +0 -101
  6. package/__tests__/benchmark-results-baseline-v1.2.0.txt +0 -354
  7. package/__tests__/benchmark-results-optimized-v2.0.0.txt +0 -354
  8. package/__tests__/benchmark-results-v3.0.0.txt +0 -372
  9. package/__tests__/benchmark.js +0 -239
  10. package/__tests__/caching-headers.test.js +0 -556
  11. package/__tests__/compression-fixtures/data.json +0 -1
  12. package/__tests__/compression-fixtures/large.txt +0 -1
  13. package/__tests__/compression-fixtures/small.txt +0 -1
  14. package/__tests__/compression.test.js +0 -284
  15. package/__tests__/customTest/README.md +0 -6
  16. package/__tests__/customTest/loadConfig.util.js +0 -41
  17. package/__tests__/customTest/serversToLoad.util.js +0 -93
  18. package/__tests__/demo-regex-index.js +0 -140
  19. package/__tests__/deprecation-warnings.test.js +0 -105
  20. package/__tests__/directory-sorting-links.test.js +0 -135
  21. package/__tests__/dt-unknown.test.js +0 -635
  22. package/__tests__/ejs.test.js +0 -299
  23. package/__tests__/head-method.test.js +0 -160
  24. package/__tests__/hidden-fixtures/.dot-dir/inside.txt +0 -1
  25. package/__tests__/hidden-fixtures/.env +0 -2
  26. package/__tests__/hidden-fixtures/.well-known/acme-challenge.txt +0 -1
  27. package/__tests__/hidden-fixtures/config/secrets/password.txt +0 -1
  28. package/__tests__/hidden-fixtures/data.key +0 -1
  29. package/__tests__/hidden-fixtures/file.secret +0 -1
  30. package/__tests__/hidden-fixtures/index.html +0 -1
  31. package/__tests__/hidden-fixtures/normal.txt +0 -1
  32. package/__tests__/hidden-fixtures/subdir/.env +0 -1
  33. package/__tests__/hidden-fixtures/subdir/regular.txt +0 -1
  34. package/__tests__/hidden-option.test.js +0 -407
  35. package/__tests__/hideExtension.test.js +0 -607
  36. package/__tests__/index-option.test.js +0 -449
  37. package/__tests__/index.test.js +0 -345
  38. package/__tests__/listing.test.js +0 -437
  39. package/__tests__/logger.test.js +0 -232
  40. package/__tests__/performance.test.js +0 -370
  41. package/__tests__/publicWwwTest/cartella/sottocartella/ciao.html +0 -11
  42. package/__tests__/publicWwwTest/cartella/sottocartella/provaEjs/testEjs.ejs +0 -11
  43. package/__tests__/publicWwwTest/cartella vuota con spazi nel nome/file con spazio nel nome .txt +0 -1
  44. package/__tests__/publicWwwTest/cartella vuota con spazi nel nome /file con spazio nel nome .txt +0 -1
  45. package/__tests__/publicWwwTest/ejs-templates/complex.ejs +0 -56
  46. package/__tests__/publicWwwTest/ejs-templates/index.ejs +0 -30
  47. package/__tests__/publicWwwTest/ejs-templates/simple.ejs +0 -13
  48. package/__tests__/publicWwwTest/ejs-templates/with-conditional.ejs +0 -28
  49. package/__tests__/publicWwwTest/ejs-templates/with-escaping.ejs +0 -26
  50. package/__tests__/publicWwwTest/ejs-templates/with-loop.ejs +0 -16
  51. package/__tests__/publicWwwTest/hideext-test/about/index.html +0 -1
  52. package/__tests__/publicWwwTest/hideext-test/about.EJS +0 -1
  53. package/__tests__/publicWwwTest/hideext-test/about.ejs +0 -2
  54. package/__tests__/publicWwwTest/hideext-test/blog/articolo.ejs +0 -2
  55. package/__tests__/publicWwwTest/hideext-test/conflict-test/pagina +0 -1
  56. package/__tests__/publicWwwTest/hideext-test/conflict-test/pagina.ejs +0 -1
  57. package/__tests__/publicWwwTest/hideext-test/file.ejs.bak +0 -1
  58. package/__tests__/publicWwwTest/hideext-test/index.ejs +0 -2
  59. package/__tests__/publicWwwTest/hideext-test/photo.txt +0 -1
  60. package/__tests__/publicWwwTest/hideext-test/sezione/index.ejs +0 -1
  61. package/__tests__/publicWwwTest/hideext-test/style.css +0 -1
  62. package/__tests__/publicWwwTest/ile_vuoto.txt +0 -0
  63. package/__tests__/publicWwwTest/index.html +0 -11
  64. package/__tests__/publicWwwTest/prova file .txt +0 -2
  65. package/__tests__/publicWwwTest/semplicetxt.txt +0 -1
  66. package/__tests__/publicWwwTest/test-page.html +0 -1
  67. package/__tests__/publicWwwTest/test.txt +0 -1
  68. package/__tests__/range-fixtures/sample.txt +0 -1
  69. package/__tests__/range.test.js +0 -223
  70. package/__tests__/security-headers.test.js +0 -165
  71. package/__tests__/security.test.js +0 -322
  72. package/__tests__/server-cache-fixtures/large.txt +0 -1
  73. package/__tests__/server-cache-fixtures/small.txt +0 -1
  74. package/__tests__/server-cache.test.js +0 -594
  75. package/__tests__/setup-benchmark.js +0 -178
  76. package/__tests__/symlink.test.js +0 -441
  77. package/__tests__/template-timeout.test.js +0 -321
  78. package/__tests__/test-regex-quick.js +0 -158
  79. package/__tests__/useOriginalUrl.test.js +0 -213
  80. package/docs/ACTION_PLAN.md +0 -293
  81. package/docs/BENCHMARKS.md +0 -317
  82. package/docs/CHANGELOG.md +0 -906
  83. package/docs/CODE_REVIEW.md +0 -300
  84. package/docs/DEBUG_REPORT.md +0 -593
  85. package/docs/DOCUMENTATION.md +0 -1864
  86. package/docs/EXAMPLES_INDEX_OPTION.md +0 -395
  87. package/docs/FLOW_DIAGRAM.md +0 -954
  88. package/docs/INDEX_OPTION_PRIORITY.md +0 -527
  89. package/docs/OPTIMIZATION_HTTP_CACHING.md +0 -689
  90. package/docs/OPTIMIZATION_ROADMAP_for_V3.md +0 -864
  91. package/docs/PERFORMANCE_ANALYSIS.md +0 -839
  92. package/docs/PERFORMANCE_COMPARISON.md +0 -388
  93. package/docs/noteExports.md +0 -148
  94. package/docs/security_improvement_for_V3.md +0 -421
  95. package/docs/template-engine/TEMPLATE_ENGINE_GUIDE.md +0 -1734
  96. package/docs/template-engine/esempi-incrementali.js +0 -192
  97. package/docs/template-engine/examples/esempio1-nessun-dato.ejs +0 -12
  98. package/docs/template-engine/examples/esempio2-una-variabile.ejs +0 -11
  99. package/docs/template-engine/examples/esempio3-piu-variabili.ejs +0 -15
  100. package/docs/template-engine/examples/esempio4-condizionale.ejs +0 -18
  101. package/docs/template-engine/examples/esempio5-loop.ejs +0 -18
  102. package/docs/template-engine/examples/index-esempi.html +0 -181
  103. package/docs/template-engine/examples/index.html +0 -40
  104. package/docs/template-engine/examples/test.ejs +0 -64
  105. package/eslint.config.mjs +0 -17
  106. package/jest.config.js +0 -18
@@ -1,135 +0,0 @@
1
- const Koa = require('koa');
2
- const request = require('supertest');
3
- const koaClassicServer = require('../index.cjs');
4
- const path = require('path');
5
-
6
- describe('Directory Sorting Links Bug Tests', () => {
7
- let app;
8
- let server;
9
-
10
- beforeAll(() => {
11
- app = new Koa();
12
- const publicDir = path.join(__dirname, 'publicWwwTest');
13
-
14
- app.use(koaClassicServer(publicDir, {
15
- method: ['GET'],
16
- dirListing: { enabled: true }
17
- }));
18
-
19
- server = app.listen();
20
- });
21
-
22
- afterAll(() => {
23
- server.close();
24
- });
25
-
26
- describe('Bug: Links with query parameters in path', () => {
27
- test('File links should not contain sort query parameters in path', async () => {
28
- const response = await request(server)
29
- .get('/?sort=name&order=asc')
30
- .expect(200);
31
-
32
- console.log('Testing for bug...');
33
- console.log('Looking for malformed URLs like: ?sort=name&order=asc/');
34
-
35
- // The bug creates malformed URLs like: href="http://localhost:3000/?sort=name&order=asc/test.txt"
36
- // Should NOT contain query params before slash
37
- expect(response.text).not.toContain('?sort=name&order=asc/');
38
-
39
- // Also check specific pattern
40
- const malformedPattern = /href="[^"]*\?sort=[^"]*\//;
41
- expect(response.text).not.toMatch(malformedPattern);
42
- });
43
-
44
- test('Directory links should not contain query parameters in path', async () => {
45
- const response = await request(server)
46
- .get('/?sort=size&order=desc')
47
- .expect(200);
48
-
49
- // Bug would create: href="http://localhost/?sort=size&order=desc/cartella"
50
- expect(response.text).not.toContain('?sort=size&order=desc/');
51
-
52
- // Check for malformed href pattern
53
- const malformedPattern = /href="[^"]*\?sort=[^"]*\//;
54
- expect(response.text).not.toMatch(malformedPattern);
55
- });
56
- });
57
-
58
- describe('Functional: Navigation after sorting', () => {
59
- test('Should enter folder after sorting by name', async () => {
60
- // Load root with sorting
61
- const rootResponse = await request(server)
62
- .get('/?sort=name&order=asc')
63
- .expect(200);
64
-
65
- expect(rootResponse.text).toContain('cartella');
66
-
67
- // Enter cartella folder
68
- const folderResponse = await request(server)
69
- .get('/cartella')
70
- .expect(200);
71
-
72
- expect(folderResponse.text).toContain('sottocartella');
73
- });
74
-
75
- test('Should navigate subfolders after sorting by size', async () => {
76
- await request(server)
77
- .get('/?sort=size&order=desc')
78
- .expect(200);
79
-
80
- // Enter cartella
81
- const folderResponse = await request(server)
82
- .get('/cartella')
83
- .expect(200);
84
-
85
- expect(folderResponse.text).toContain('sottocartella');
86
-
87
- // Enter sottocartella
88
- const subfolderResponse = await request(server)
89
- .get('/cartella/sottocartella')
90
- .expect(200);
91
-
92
- expect(subfolderResponse.text).toContain('ciao.html');
93
- });
94
-
95
- test('Should access file after sorting by type', async () => {
96
- await request(server)
97
- .get('/?sort=type&order=asc')
98
- .expect(200);
99
-
100
- // Access file
101
- const fileResponse = await request(server)
102
- .get('/test.txt')
103
- .expect(200);
104
-
105
- expect(fileResponse.text).toContain('hello world');
106
- });
107
- });
108
-
109
- describe('Regression: Sort links still work', () => {
110
- test('Sort header links should work', async () => {
111
- const response = await request(server)
112
- .get('/')
113
- .expect(200);
114
-
115
- // Sort links SHOULD have query parameters
116
- expect(response.text).toContain('?sort=name');
117
- expect(response.text).toContain('?sort=type');
118
- expect(response.text).toContain('?sort=size');
119
- });
120
-
121
- test('Sort indicators should toggle', async () => {
122
- const response1 = await request(server)
123
- .get('/?sort=name&order=asc')
124
- .expect(200);
125
-
126
- expect(response1.text).toContain('↑');
127
-
128
- const response2 = await request(server)
129
- .get('/?sort=name&order=desc')
130
- .expect(200);
131
-
132
- expect(response2.text).toContain('↓');
133
- });
134
- });
135
- });