()
| 222 | } |
| 223 | |
| 224 | async function sendByExt() { |
| 225 | if (isConsole) { |
| 226 | if (reqPath === "console.html") { |
| 227 | sendText( |
| 228 | mustache.render($_console, { |
| 229 | CONSOLE_SCRIPT, |
| 230 | EXECUTING_SCRIPT, |
| 231 | }), |
| 232 | reqId, |
| 233 | MIMETYPE_HTML, |
| 234 | ); |
| 235 | return; |
| 236 | } |
| 237 | |
| 238 | if (reqPath === "favicon.ico") { |
| 239 | sendIco(ASSETS_DIRECTORY, reqId); |
| 240 | return; |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | if (activeFile.SAFMode === "single") { |
| 245 | if (filename === reqPath) { |
| 246 | sendText( |
| 247 | activeFile.session?.doc?.toString(), |
| 248 | reqId, |
| 249 | mimeType.lookup(filename), |
| 250 | ); |
| 251 | } else { |
| 252 | error(reqId); |
| 253 | } |
| 254 | return; |
| 255 | } |
| 256 | |
| 257 | let url = activeFile.uri; |
| 258 | let file = activeFile.SAFMode === "single" ? activeFile : null; |
| 259 | |
| 260 | if (pathName) { |
| 261 | url = Url.join(pathName, reqPath); |
| 262 | file = editorManager.getFile(url, "uri"); |
| 263 | } else if (!activeFile.uri && filename === reqPath) { |
| 264 | file = activeFile; |
| 265 | } |
| 266 | |
| 267 | if (!url && !file) { |
| 268 | error(reqId); |
| 269 | return; |
| 270 | } |
| 271 | |
| 272 | // Handle extensionless URLs (e.g., "about" -> "about.html" or "about/index.html") |
| 273 | if (!ext && pathName) { |
| 274 | // Try exact match first for extensionless files (LICENSE, README, etc.) |
| 275 | const exactUrl = Url.join(pathName, reqPath); |
| 276 | const exactFs = fsOperation(exactUrl); |
| 277 | if (await exactFs.exists()) { |
| 278 | sendFile(exactUrl, reqId); |
| 279 | return; |
| 280 | } |
| 281 |
no test coverage detected