Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,25 @@ export class App {
}

// respondStatic returns Response with static file gotten from a path. If a given path didn't match, this method returns null.
//FIXME: does not get js file in public directory, linked from HTML -> responds from normal
private async respondStatic(path: string): Promise<Response | null> {
let fileInfo: Deno.FileInfo | null = null;
let staticFilePath = `${this.publicDir}${path}`;

try {
fileInfo = await stat(staticFilePath);
} catch (e) {
// Do nothing here.
}
if (fileInfo && fileInfo.isDirectory()) {
if (fileInfo && fileInfo.isDirectory) {
staticFilePath += "/index.html";
try {
fileInfo = await stat(staticFilePath);
} catch (e) {
fileInfo = null; // FileInfo is not needed any more.
}
}
if (!fileInfo || !fileInfo.isFile()) {
if (!fileInfo || !fileInfo.isFile) {
return null;
}
return [
Expand Down Expand Up @@ -166,6 +168,11 @@ export class App {
}
}

//FIXME: find proper solutin for files that are linked from HTML (would default to standard GET and not static)
if (path.endsWith(".js")) {
return null; // assume this is a static file
}

const ctx = { path, method, params };
const res = handler(ctx);
if (res instanceof Promise) {
Expand Down
2 changes: 1 addition & 1 deletion vendor/https/deno.land/std/encoding/utf8.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from 'https://deno.land/std@v0.40.0/encoding/utf8.ts';
export * from "https://deno.land/std@v0.40.0/encoding/utf8.ts";
2 changes: 1 addition & 1 deletion vendor/https/deno.land/std/flags/mod.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from 'https://deno.land/std@v0.40.0/flags/mod.ts';
export * from "https://deno.land/std@v0.40.0/flags/mod.ts";
2 changes: 1 addition & 1 deletion vendor/https/deno.land/std/http/server.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from 'https://deno.land/std@v0.40.0/http/server.ts';
export * from "https://deno.land/std@v0.40.0/http/server.ts";
2 changes: 1 addition & 1 deletion vendor/https/deno.land/std/testing/asserts.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from 'https://deno.land/std@v0.40.0/testing/asserts.ts';
export * from "https://deno.land/std@v0.40.0/testing/asserts.ts";