fix(server): properly sanitize island names (#1393)
Co-authored-by: Lino Le Van <11367844+lino-levan@users.noreply.github.com>
This commit is contained in:
co-authored by
Lino Le Van
parent
ced2215446
commit
eb53d53ab8
@@ -931,7 +931,7 @@ function toPascalCase(text: string): string {
|
||||
}
|
||||
|
||||
function sanitizeIslandName(name: string): string {
|
||||
const fileName = name.replace("/", "");
|
||||
const fileName = name.replaceAll("/", "_");
|
||||
return toPascalCase(fileName);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,8 @@ import * as $$2 from "./islands/RootFragment.tsx";
|
||||
import * as $$3 from "./islands/RootFragmentWithConditionalFirst.tsx";
|
||||
import * as $$4 from "./islands/Test.tsx";
|
||||
import * as $$5 from "./islands/folder/Counter.tsx";
|
||||
import * as $$6 from "./islands/kebab-case-counter-test.tsx";
|
||||
import * as $$6 from "./islands/folder/subfolder/Counter.tsx";
|
||||
import * as $$7 from "./islands/kebab-case-counter-test.tsx";
|
||||
|
||||
const manifest = {
|
||||
routes: {
|
||||
@@ -90,7 +91,8 @@ const manifest = {
|
||||
"./islands/RootFragmentWithConditionalFirst.tsx": $$3,
|
||||
"./islands/Test.tsx": $$4,
|
||||
"./islands/folder/Counter.tsx": $$5,
|
||||
"./islands/kebab-case-counter-test.tsx": $$6,
|
||||
"./islands/folder/subfolder/Counter.tsx": $$6,
|
||||
"./islands/kebab-case-counter-test.tsx": $$7,
|
||||
},
|
||||
baseUrl: import.meta.url,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import type { Signal } from "@preact/signals";
|
||||
import { IS_BROWSER } from "$fresh/runtime.ts";
|
||||
|
||||
interface CounterProps {
|
||||
count: Signal<number>;
|
||||
id: string;
|
||||
}
|
||||
|
||||
export default function Counter(props: CounterProps) {
|
||||
return (
|
||||
<div id={props.id}>
|
||||
<p>{props.count}</p>
|
||||
<button
|
||||
id={`b-${props.id}`}
|
||||
onClick={() => props.count.value += 1}
|
||||
disabled={!IS_BROWSER}
|
||||
>
|
||||
+1
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useSignal } from "@preact/signals";
|
||||
import Counter from "../../islands/Counter.tsx";
|
||||
import FolderCounter from "../../islands/folder/Counter.tsx";
|
||||
import SubfolderCounter from "../../islands/folder/subfolder/Counter.tsx";
|
||||
import KebabCaseFileNameTest from "../../islands/kebab-case-counter-test.tsx";
|
||||
import Test from "../../islands/Test.tsx";
|
||||
|
||||
@@ -10,6 +11,7 @@ export default function Home() {
|
||||
<Counter id="counter1" count={useSignal(3)} />
|
||||
<Counter id="counter2" count={useSignal(10)} />
|
||||
<FolderCounter id="folder-counter" count={useSignal(3)} />
|
||||
<SubfolderCounter id="subfolder-counter" count={useSignal(3)} />
|
||||
<KebabCaseFileNameTest
|
||||
id="kebab-case-file-counter"
|
||||
count={useSignal(5)}
|
||||
|
||||
@@ -30,10 +30,11 @@ Deno.test({
|
||||
waitUntil: "networkidle2",
|
||||
});
|
||||
|
||||
await t.step("Ensure 4 islands on 1 page are revived", async () => {
|
||||
await t.step("Ensure 5 islands on 1 page are revived", async () => {
|
||||
await counterTest("counter1", 3);
|
||||
await counterTest("counter2", 10);
|
||||
await counterTest("folder-counter", 3);
|
||||
await counterTest("subfolder-counter", 3);
|
||||
await counterTest("kebab-case-file-counter", 5);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user