Commit ef96ffe
committed
fix(serve): a real public file beats any dynamic route, not just a catch-all
The disk check added in 0.2.174 only dropped `[...catch-all]` candidates, on
the assumption that those are the routes broad enough to swallow an asset.
That assumption holds for a shallow route tree and fails completely for an app
whose routes start at the root: a forge with `[owner]/[repository]` claims
every two-segment path and `[owner]` claims every one-segment path, so
`/js/mermaid.js` and `/favicon.ico` both rendered a page and **the entire
publicDir was unreachable**.
Found by loading a page that dynamically imports `/js/mermaid.js` and getting
72KB of HTML where the 3.4MB bundle should have been - every mermaid diagram
in that product silently not drawing, on the served boot as well as the dev
server, with the fallback leaving the diagram source on screen so it read as
"no diagram here" rather than as a failure.
A file that really exists at exactly the requested path is a stronger signal
than any route pattern, so it now wins over all of them. Nothing is dropped
when publicDir has nothing there, which is what keeps
`/owner/repo/tree/main/src/index.ts` resolving to the code browser.
The resolver test mirrored the old rule and would have kept passing while the
server did something else; it mirrors the new one now, with the forge's own
route shape as the case.1 parent 43a9693 commit ef96ffe
2 files changed
Lines changed: 38 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2423 | 2423 | | |
2424 | 2424 | | |
2425 | 2425 | | |
2426 | | - | |
2427 | | - | |
2428 | | - | |
2429 | | - | |
| 2426 | + | |
| 2427 | + | |
| 2428 | + | |
| 2429 | + | |
| 2430 | + | |
| 2431 | + | |
| 2432 | + | |
| 2433 | + | |
| 2434 | + | |
| 2435 | + | |
| 2436 | + | |
| 2437 | + | |
2430 | 2438 | | |
2431 | 2439 | | |
2432 | 2440 | | |
2433 | 2441 | | |
2434 | 2442 | | |
2435 | 2443 | | |
2436 | | - | |
| 2444 | + | |
2437 | 2445 | | |
2438 | 2446 | | |
2439 | 2447 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
| 113 | + | |
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
| 119 | + | |
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
| 141 | + | |
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
153 | 169 | | |
154 | 170 | | |
155 | 171 | | |
| |||
0 commit comments