koa-classic-server 3.0.0 → 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.
- package/README.md +44 -120
- package/index.cjs +236 -21
- package/package.json +10 -5
- package/.github/workflows/npm-publish.yml +0 -98
- package/CLAUDE.md +0 -101
- package/__tests__/benchmark-results-baseline-v1.2.0.txt +0 -354
- package/__tests__/benchmark-results-optimized-v2.0.0.txt +0 -354
- package/__tests__/benchmark-results-v3.0.0.txt +0 -372
- package/__tests__/benchmark.js +0 -239
- package/__tests__/caching-headers.test.js +0 -556
- package/__tests__/compression-fixtures/data.json +0 -1
- package/__tests__/compression-fixtures/large.txt +0 -1
- package/__tests__/compression-fixtures/small.txt +0 -1
- package/__tests__/compression.test.js +0 -284
- package/__tests__/customTest/README.md +0 -6
- package/__tests__/customTest/loadConfig.util.js +0 -41
- package/__tests__/customTest/serversToLoad.util.js +0 -93
- package/__tests__/demo-regex-index.js +0 -140
- package/__tests__/deprecation-warnings.test.js +0 -105
- package/__tests__/directory-sorting-links.test.js +0 -135
- package/__tests__/dt-unknown.test.js +0 -635
- package/__tests__/ejs.test.js +0 -299
- package/__tests__/hidden-fixtures/.dot-dir/inside.txt +0 -1
- package/__tests__/hidden-fixtures/.env +0 -2
- package/__tests__/hidden-fixtures/.well-known/acme-challenge.txt +0 -1
- package/__tests__/hidden-fixtures/config/secrets/password.txt +0 -1
- package/__tests__/hidden-fixtures/data.key +0 -1
- package/__tests__/hidden-fixtures/file.secret +0 -1
- package/__tests__/hidden-fixtures/index.html +0 -1
- package/__tests__/hidden-fixtures/normal.txt +0 -1
- package/__tests__/hidden-fixtures/subdir/.env +0 -1
- package/__tests__/hidden-fixtures/subdir/regular.txt +0 -1
- package/__tests__/hidden-option.test.js +0 -407
- package/__tests__/hideExtension.test.js +0 -607
- package/__tests__/index-option.test.js +0 -449
- package/__tests__/index.test.js +0 -345
- package/__tests__/listing.test.js +0 -437
- package/__tests__/logger.test.js +0 -232
- package/__tests__/performance.test.js +0 -370
- package/__tests__/publicWwwTest/cartella/sottocartella/ciao.html +0 -11
- package/__tests__/publicWwwTest/cartella/sottocartella/provaEjs/testEjs.ejs +0 -11
- package/__tests__/publicWwwTest/cartella vuota con spazi nel nome/file con spazio nel nome .txt +0 -1
- package/__tests__/publicWwwTest/cartella vuota con spazi nel nome /file con spazio nel nome .txt +0 -1
- package/__tests__/publicWwwTest/ejs-templates/complex.ejs +0 -56
- package/__tests__/publicWwwTest/ejs-templates/index.ejs +0 -30
- package/__tests__/publicWwwTest/ejs-templates/simple.ejs +0 -13
- package/__tests__/publicWwwTest/ejs-templates/with-conditional.ejs +0 -28
- package/__tests__/publicWwwTest/ejs-templates/with-escaping.ejs +0 -26
- package/__tests__/publicWwwTest/ejs-templates/with-loop.ejs +0 -16
- package/__tests__/publicWwwTest/hideext-test/about/index.html +0 -1
- package/__tests__/publicWwwTest/hideext-test/about.EJS +0 -1
- package/__tests__/publicWwwTest/hideext-test/about.ejs +0 -2
- package/__tests__/publicWwwTest/hideext-test/blog/articolo.ejs +0 -2
- package/__tests__/publicWwwTest/hideext-test/conflict-test/pagina +0 -1
- package/__tests__/publicWwwTest/hideext-test/conflict-test/pagina.ejs +0 -1
- package/__tests__/publicWwwTest/hideext-test/file.ejs.bak +0 -1
- package/__tests__/publicWwwTest/hideext-test/index.ejs +0 -2
- package/__tests__/publicWwwTest/hideext-test/photo.txt +0 -1
- package/__tests__/publicWwwTest/hideext-test/sezione/index.ejs +0 -1
- package/__tests__/publicWwwTest/hideext-test/style.css +0 -1
- package/__tests__/publicWwwTest/ile_vuoto.txt +0 -0
- package/__tests__/publicWwwTest/index.html +0 -11
- package/__tests__/publicWwwTest/prova file .txt +0 -2
- package/__tests__/publicWwwTest/semplicetxt.txt +0 -1
- package/__tests__/publicWwwTest/test-page.html +0 -1
- package/__tests__/publicWwwTest/test.txt +0 -1
- package/__tests__/range-fixtures/sample.txt +0 -1
- package/__tests__/range.test.js +0 -223
- package/__tests__/security-headers.test.js +0 -165
- package/__tests__/security.test.js +0 -322
- package/__tests__/server-cache-fixtures/large.txt +0 -1
- package/__tests__/server-cache-fixtures/small.txt +0 -1
- package/__tests__/server-cache.test.js +0 -594
- package/__tests__/setup-benchmark.js +0 -178
- package/__tests__/symlink.test.js +0 -441
- package/__tests__/template-timeout.test.js +0 -321
- package/__tests__/test-regex-quick.js +0 -158
- package/__tests__/useOriginalUrl.test.js +0 -213
- package/docs/ACTION_PLAN.md +0 -293
- package/docs/BENCHMARKS.md +0 -317
- package/docs/CHANGELOG.md +0 -880
- package/docs/CODE_REVIEW.md +0 -300
- package/docs/DEBUG_REPORT.md +0 -593
- package/docs/DOCUMENTATION.md +0 -1864
- package/docs/EXAMPLES_INDEX_OPTION.md +0 -395
- package/docs/FLOW_DIAGRAM.md +0 -954
- package/docs/INDEX_OPTION_PRIORITY.md +0 -527
- package/docs/OPTIMIZATION_HTTP_CACHING.md +0 -689
- package/docs/OPTIMIZATION_ROADMAP_for_V3.md +0 -864
- package/docs/PERFORMANCE_ANALYSIS.md +0 -839
- package/docs/PERFORMANCE_COMPARISON.md +0 -388
- package/docs/noteExports.md +0 -148
- package/docs/security_improvement_for_V3.md +0 -421
- package/docs/template-engine/TEMPLATE_ENGINE_GUIDE.md +0 -1734
- package/docs/template-engine/esempi-incrementali.js +0 -192
- package/docs/template-engine/examples/esempio1-nessun-dato.ejs +0 -12
- package/docs/template-engine/examples/esempio2-una-variabile.ejs +0 -11
- package/docs/template-engine/examples/esempio3-piu-variabili.ejs +0 -15
- package/docs/template-engine/examples/esempio4-condizionale.ejs +0 -18
- package/docs/template-engine/examples/esempio5-loop.ejs +0 -18
- package/docs/template-engine/examples/index-esempi.html +0 -181
- package/docs/template-engine/examples/index.html +0 -40
- package/docs/template-engine/examples/test.ejs +0 -64
- package/eslint.config.mjs +0 -17
- 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
|
-
});
|