Allow search params (#1927)

Fixes #1795
This commit is contained in:
Drew Powers 2021-11-19 12:57:24 -07:00 committed by GitHub
parent 1692675575
commit f7b23d5cf1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -110,7 +110,7 @@ export class AstroDevServer {
}
const route = this.mostRecentRoute;
const pathname = route?.pathname ?? '/';
const [pathname, search = undefined] = (route?.pathname ?? '/').split('?');
if (!route) {
viteServer.ws.send({
@ -274,7 +274,7 @@ export class AstroDevServer {
private async handleRequest(req: http.IncomingMessage, res: http.ServerResponse, next: NextFunction) {
if (!this.viteServer) throw new Error(`AstroDevServer.start() not called`);
let pathname = req.url || '/'; // original request
let [pathname, search = undefined] = (req.url || '/').split('?'); // original request
const reqStart = performance.now();
let filePath: URL | undefined;
try {

View file

@ -23,6 +23,11 @@ describe('Development Routing', () => {
expect(response.status).to.equal(200);
});
it('200 when adding search params', async () => {
const response = await fixture.fetch('/?foo=bar');
expect(response.status).to.equal(200);
});
it('200 when loading non-root page', async () => {
const response = await fixture.fetch('/another');
expect(response.status).to.equal(200);