Skip to content

framework: publicDir gives 404 for a URL with a query string or a percent-encoded file name #769

Open

Description

@lionelhorn

A file in publicDir is not found when its URL has a query string, or when its name has characters a browser percent-encodes (spaces, non-ASCII).

import { mkdtempSync, writeFileSync } from 'fs';
import { tmpdir } from 'os';
import { join } from 'path';
import { App } from '@deepkit/app';
import { FrameworkModule } from '@deepkit/framework';
import { HttpKernel, HttpRequest } from '@deepkit/http';

const publicDir = mkdtempSync(join(tmpdir(), 'public-'));
writeFileSync(join(publicDir, 'app.js'), 'console.log(1)');
writeFileSync(join(publicDir, 'price list.txt'), 'prices');

const app = new App({ imports: [new FrameworkModule({ publicDir })] });
const kernel = app.get(HttpKernel);

for (const url of ['/app.js', '/app.js?v=123', '/price%20list.txt']) {
    const response = await kernel.request(HttpRequest.GET(url));
    console.log(url, response.statusCode, response.bodyString);
}
// /app.js:           200 console.log(1)
// /app.js?v=123:     actual 404 Not found, should be: 200 console.log(1)
// /price%20list.txt: actual 404 Not found, should be: 200 prices

Master 0bb9fba, Node 26.13.0.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions