feat: co-locate islands + non-route files (#1600)

This commit is contained in:
Marvin Hagemeister
2023-08-07 20:33:08 +02:00
committed by GitHub
parent d8211dad28
commit 97c6876bf7
9 changed files with 171 additions and 67 deletions
+6 -3
View File
@@ -317,8 +317,11 @@ export class ServerContext {
if (!url.startsWith(baseUrl)) {
throw new TypeError("Island is not a child of the basepath.");
}
const path = url.substring(baseUrl.length).substring("islands".length);
const baseRoute = path.substring(1, path.length - extname(path).length);
let path = url.substring(baseUrl.length);
if (path.startsWith("islands")) {
path = path.slice("islands".length + 1);
}
const baseRoute = path.substring(0, path.length - extname(path).length);
for (const [exportName, exportedFunction] of Object.entries(module)) {
if (typeof exportedFunction !== "function") {
@@ -1154,7 +1157,7 @@ function toPascalCase(text: string): string {
}
function sanitizeIslandName(name: string): string {
const fileName = name.replaceAll("/", "_");
const fileName = name.replaceAll(/[/\\\\\(\)]/g, "_");
return toPascalCase(fileName);
}