Skip to content

Commit

Permalink
add no file extension handling
Browse files Browse the repository at this point in the history
  • Loading branch information
FredKSchott committed Oct 12, 2020
1 parent 1f476b2 commit 442ad85
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions snowpack/src/commands/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const sendFile = (
res: http.ServerResponse,
body: string | Buffer,
fileLoc: string,
ext = '.html',
ext: string,
) => {
body = Buffer.from(body);
const ETag = etag(body, {weak: true});
Expand Down Expand Up @@ -424,9 +424,6 @@ export async function startServer(commandOptions: CommandOptions) {
let responseFileExt = requestedFileExt;
let isRoute = !requestedFileExt || requestedFileExt === '.html';

// Now that we've set isRoute properly, give `requestedFileExt` a fallback
requestedFileExt = requestedFileExt || '.html';

async function getFileFromUrl(reqPath: string): Promise<string | null> {
if (reqPath.startsWith(config.buildOptions.webModulesUrl)) {
const dependencyFileLoc =
Expand Down Expand Up @@ -471,11 +468,11 @@ export async function startServer(commandOptions: CommandOptions) {
continue;
}
let fileLoc =
(await attemptLoadFile(requestedFile)) ||
(await attemptLoadFile(requestedFile + '.html')) ||
(await attemptLoadFile(requestedFile + 'index.html')) ||
(await attemptLoadFile(requestedFile + '/index.html'));
if (fileLoc) {
requestedFileExt = '.html';
responseFileExt = '.html';
return fileLoc;
}
Expand All @@ -493,6 +490,7 @@ export async function startServer(commandOptions: CommandOptions) {
fileLoc = await attemptLoadFile(fallbackFile);
}
if (fileLoc) {
requestedFileExt = '.html';
responseFileExt = '.html';
return fileLoc;
}
Expand Down

0 comments on commit 442ad85

Please sign in to comment.