Skip to content

Commit 1482f9f

Browse files
committed
fix: resolve GitHub URI preview issues in server
- Disable overlap detection for GitHub URIs to prevent path corruption (index.html becoming dex.html)
1 parent 3d5f90a commit 1482f9f

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

src/lib/run.js

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -319,34 +319,42 @@ async function run(
319319

320320
console.log(`RootFolder ${rootFolder}`);
321321
console.log(`PARTS ${pathParts.join("/")}`);
322-
const overlap = findOverlap(rootFolder, pathParts.join("/"));
323322

324323
let fullPath;
325-
if (overlap !== "") {
326-
fullPath = Url.join(
327-
rootFolder,
328-
removePrefix(pathParts.join("/"), overlap),
329-
);
330-
} else {
324+
// Skip overlap detection for GitHub URIs as it causes path corruption
325+
if (rootFolder.startsWith("gh://")) {
331326
fullPath = Url.join(rootFolder, pathParts.join("/"));
327+
} else {
328+
const overlap = findOverlap(rootFolder, pathParts.join("/"));
329+
if (overlap !== "") {
330+
fullPath = Url.join(
331+
rootFolder,
332+
removePrefix(pathParts.join("/"), overlap),
333+
);
334+
} else {
335+
fullPath = Url.join(rootFolder, pathParts.join("/"));
336+
}
332337
}
333338

334339
console.log(`Full PATH ${fullPath}`);
335340

336341
const urlFile = fsOperation(fullPath);
337342

338-
const stats = await urlFile.stat();
343+
// Skip stat check for GitHub URIs as they are handled differently
344+
if (!fullPath.startsWith("gh://")) {
345+
const stats = await urlFile.stat();
339346

340-
if (!stats.exists) {
341-
error(reqId);
342-
return;
343-
}
347+
if (!stats.exists) {
348+
error(reqId);
349+
return;
350+
}
344351

345-
if (!stats.isFile) {
346-
if (fullPath.endsWith("/")) {
347-
fullPath += "index.html";
348-
} else {
349-
fullPath += "/index.html";
352+
if (!stats.isFile) {
353+
if (fullPath.endsWith("/")) {
354+
fullPath += "index.html";
355+
} else {
356+
fullPath += "/index.html";
357+
}
350358
}
351359
}
352360

0 commit comments

Comments
 (0)