Skip to content

Commit 0de6858

Browse files
committed
fix: allow dotted text bodies in Server#get routes
1 parent 2a7382e commit 0de6858

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

lib/server/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ class Server extends HttpServer {
5858
const ext = extname(body || path)
5959
const mime = this.#config.mime[ext]
6060

61-
if (body && ext && !mime)
62-
throw new Error(`${ext}: not in mime`)
63-
6461
return mime
6562
? this.#addPage(path, body || path.slice(1))
6663
: this.#addRoute(path, body || 'ok')

lib/server/test/main.test.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,17 @@ test('#Server', async t => {
5454
})
5555

5656
await t.test('body with unknown extension', async t => {
57-
await t.test('throws', t => {
58-
t.assert.throws(
59-
() => t.server.get('/foo', 'bar.xyz'),
60-
{ message: /not in mime/i }
57+
await t.test('chains as text route', t => {
58+
t.assert.strictEqual(
59+
t.server.get('/foo', 'bar.xyz'), t.server
60+
)
61+
})
62+
})
63+
64+
await t.test('body with dotted text', async t => {
65+
await t.test('chains as text route', t => {
66+
t.assert.strictEqual(
67+
t.server.get('/version', 'v1.0.0'), t.server
6168
)
6269
})
6370
})

0 commit comments

Comments
 (0)