feat: add support for optional dynamic route params (#1706)
This commit is contained in:
@@ -217,6 +217,26 @@ Deno.test("/books/:id page - /books/abc", async () => {
|
||||
assertEquals(resp.status, Status.NotFound);
|
||||
});
|
||||
|
||||
Deno.test("/i18n{/:lang}?/lang page - /i18n/lang", async () => {
|
||||
const resp = await handler(new Request("https://fresh.deno.dev/i18n/lang"));
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.headers.get("content-type"), "text/html; charset=utf-8");
|
||||
const body = await resp.text();
|
||||
assertStringIncludes(body, "<div>Hello</div>");
|
||||
});
|
||||
|
||||
Deno.test("/i18n{/:lang}?/lang page - /i18n/en/lang", async () => {
|
||||
const resp = await handler(
|
||||
new Request("https://fresh.deno.dev/i18n/en/lang"),
|
||||
);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.headers.get("content-type"), "text/html; charset=utf-8");
|
||||
const body = await resp.text();
|
||||
assertStringIncludes(body, "<div>Hello en</div>");
|
||||
});
|
||||
|
||||
Deno.test("redirect /pages/fresh/ to /pages/fresh", async () => {
|
||||
const resp = await handler(
|
||||
new Request("https://fresh.deno.dev/pages/fresh/"),
|
||||
|
||||
Reference in New Issue
Block a user