feat(server): Add basePath config to host from a directory (#2092)
Co-authored-by: Marvin Hagemeister <marvin@deno.com>
This commit is contained in:
co-authored by
Marvin Hagemeister
parent
fe792455ab
commit
9ab8651018
@@ -26,6 +26,7 @@ import {
|
||||
dirname,
|
||||
extname,
|
||||
join,
|
||||
SEP,
|
||||
toFileUrl,
|
||||
walk,
|
||||
} from "./deps.ts";
|
||||
@@ -107,8 +108,12 @@ export async function extractRoutes(
|
||||
throw new TypeError("Page is not a child of the basepath.");
|
||||
}
|
||||
const path = url.substring(baseUrl.length + "routes".length);
|
||||
const baseRoute = path.substring(1, path.length - extname(path).length);
|
||||
const name = baseRoute.replace("/", "-");
|
||||
let baseRoute = path.substring(1, path.length - extname(path).length);
|
||||
baseRoute = join(state.config.basePath.slice(1), baseRoute).replaceAll(
|
||||
SEP,
|
||||
"/",
|
||||
);
|
||||
const name = baseRoute.replace(/\//g, "-");
|
||||
const isLayout = path.endsWith("/_layout.tsx") ||
|
||||
path.endsWith("/_layout.ts") || path.endsWith("/_layout.jsx") ||
|
||||
path.endsWith("/_layout.js");
|
||||
@@ -328,7 +333,7 @@ export async function extractRoutes(
|
||||
);
|
||||
const staticFile: StaticFile = {
|
||||
localUrl,
|
||||
path,
|
||||
path: join(state.config.basePath, path),
|
||||
size: stat.size,
|
||||
contentType: type,
|
||||
etag,
|
||||
|
||||
Reference in New Issue
Block a user