mirror of
https://github.com/morluto/rea.git
synced 2026-11-12 01:41:21 +00:00
fix(javascript): retain anchored route constants under reserved prefixes (#7838)
This commit is contained in:
1 parent
0759fb9ad5
commit
9b7c2bb1ac
3 files changed
+50
-5
No files matched your search
@@ -204,6 +204,33 @@ it("binds ordinary constants to application segments across sources and excludes
|
||||
]);
|
||||
expect(result.statistics.unanchored_literals_excluded).toBe(2);
|
||||
});
|
||||
it.each(["api", "assets", "static", "_next"])(
|
||||
"retains constants under an anchored %s segment without promoting unanchored paths",
|
||||
(prefix) => {
|
||||
const result = build([
|
||||
source("route.js", `router.push('/${prefix}/status');`),
|
||||
source(
|
||||
"runtime.js",
|
||||
`globalThis.TURBOPACK=[];const same='/${prefix}/status';const help='/${prefix}/help';const other='/unanchored/noise';`,
|
||||
),
|
||||
]);
|
||||
const anchored = result.routes.find(
|
||||
({ path }) => path === `/${prefix}/status`,
|
||||
);
|
||||
const descendant = result.routes.find(
|
||||
({ path }) => path === `/${prefix}/help`,
|
||||
);
|
||||
expect(anchored).toMatchObject({ occurrence_count: 2, source_count: 2 });
|
||||
expect(descendant).toMatchObject({
|
||||
confidence: "low",
|
||||
classification: "unknown",
|
||||
});
|
||||
expect(result.routes.some(({ path }) => path === "/unanchored/noise")).toBe(
|
||||
false,
|
||||
);
|
||||
expect(result.coverage.application_routes).toBe("unknown");
|
||||
},
|
||||
);
|
||||
it("retains inferred Next script bases and the unprefixed path", () => {
|
||||
const result = build([
|
||||
source(
|
||||
|
||||
Reference in new issue
Block a user