mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
[FileSystemRouter] Fix reload()
This commit is contained in:
@@ -320,7 +320,7 @@ pub const FileSystemRouter = struct {
|
||||
};
|
||||
|
||||
var router = Router.init(vm.bundler.fs, allocator, .{
|
||||
.dir = this.router.config.dir,
|
||||
.dir = allocator.dupe(u8, this.router.config.dir) catch unreachable,
|
||||
.extensions = allocator.dupe(string, this.router.config.extensions) catch unreachable,
|
||||
.asset_prefix_path = this.router.config.asset_prefix_path,
|
||||
}) catch unreachable;
|
||||
@@ -338,6 +338,7 @@ pub const FileSystemRouter = struct {
|
||||
this.arena = arena;
|
||||
@This().routesSetCached(this_value, globalThis, JSC.JSValue.zero);
|
||||
this.allocator = allocator;
|
||||
this.router = router;
|
||||
return this_value;
|
||||
}
|
||||
|
||||
|
||||
@@ -349,6 +349,22 @@ it(".query works", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("reload() works", () => {
|
||||
// set up the test
|
||||
const { dir } = make(["posts.tsx"]);
|
||||
|
||||
const router = new Bun.FileSystemRouter({
|
||||
dir,
|
||||
style: "nextjs",
|
||||
assetPrefix: "/_next/static/",
|
||||
origin: "https://nextjs.org",
|
||||
});
|
||||
|
||||
expect(router.match("/posts").name).toBe("/posts");
|
||||
router.reload();
|
||||
expect(router.match("/posts").name).toBe("/posts");
|
||||
});
|
||||
|
||||
it(".query works with dynamic routes, including params", () => {
|
||||
// set up the test
|
||||
const { dir } = make(["posts/[id].tsx"]);
|
||||
|
||||
Reference in New Issue
Block a user