Skip to content

Commit de6ca25

Browse files
format
1 parent bd8a2fa commit de6ca25

1 file changed

Lines changed: 23 additions & 17 deletions

File tree

src/lib/run.js

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ import helpers from "utils/helpers";
1414
import Url from "utils/Url";
1515
import $_console from "views/console.hbs";
1616
import $_markdown from "views/markdown.hbs";
17+
import { SAFDocumentFile } from "../fileSystem/SAFDocumentFile";
1718
import constants from "./constants";
1819
import EditorFile from "./editorFile";
1920
import openFolder, { addedFolder } from "./openFolder";
2021
import appSettings from "./settings";
21-
import { SAFDocumentFile } from "../fileSystem/SAFDocumentFile";
2222

2323
/**@type {Server} */
2424
let webServer;
@@ -303,7 +303,7 @@ async function run(
303303
const rootFile = new SAFDocumentFile(rootFolder);
304304

305305
// Split the request path to navigate through directories
306-
const pathParts = reqPath.split("/").filter(p => p);
306+
const pathParts = reqPath.split("/").filter((p) => p);
307307

308308
// Start from root and navigate to the requested file
309309
let currentFile = rootFile;
@@ -494,20 +494,22 @@ async function run(
494494
theme: 'dark'
495495
});
496496
497-
${target === "inapp"
498-
? "eruda._shadowRoot.querySelector('.eruda-entry-btn').style.display = 'none';"
499-
: ""
500-
}
497+
${
498+
target === "inapp"
499+
? "eruda._shadowRoot.querySelector('.eruda-entry-btn').style.display = 'none';"
500+
: ""
501+
}
501502
502503
sessionStorage.setItem('__console_available', true);
503504
document.addEventListener('showconsole', function () {eruda.show()});
504505
document.addEventListener('hideconsole', function () {eruda.hide()});
505506
}else if(document.querySelector('c-toggler')){
506-
${target === "inapp" ||
507-
(target !== "inapp" && !appSettings.value.showConsoleToggler)
508-
? "document.querySelector('c-toggler').style.display = 'none';"
509-
: ""
510-
}
507+
${
508+
target === "inapp" ||
509+
(target !== "inapp" && !appSettings.value.showConsoleToggler)
510+
? "document.querySelector('c-toggler').style.display = 'none';"
511+
: ""
512+
}
511513
}
512514
setTimeout(function(){
513515
var scripts = document.querySelectorAll('.${uuid}');
@@ -660,7 +662,11 @@ async function run(
660662
let rootFolder = pathName;
661663

662664
// Use SAFDocumentFile for Android content URIs
663-
if (activeFile && activeFile.uri && activeFile.uri.startsWith("content://")) {
665+
if (
666+
activeFile &&
667+
activeFile.uri &&
668+
activeFile.uri.startsWith("content://")
669+
) {
664670
try {
665671
console.log(`DEBUG - Using SAFDocumentFile for URI: ${activeFile.uri}`);
666672

@@ -690,8 +696,8 @@ async function run(
690696
console.log(`DEBUG - Checking parent URI: ${parentUri}`);
691697

692698
// Normalize URIs for comparison
693-
const normalizedParentUri = parentUri.replace(/\/+$/, '');
694-
const normalizedRootFolder = rootFolder.replace(/\/+$/, '');
699+
const normalizedParentUri = parentUri.replace(/\/+$/, "");
700+
const normalizedRootFolder = rootFolder.replace(/\/+$/, "");
695701

696702
if (normalizedParentUri === normalizedRootFolder) {
697703
console.log(`DEBUG - Reached root folder`);
@@ -706,7 +712,7 @@ async function run(
706712
parent = await current.getParentFile();
707713
}
708714

709-
const relativePath = relativeParts.join('/');
715+
const relativePath = relativeParts.join("/");
710716
console.log(`DEBUG - Final SAF relative path: ${relativePath}`);
711717
return relativePath;
712718
} else {
@@ -715,7 +721,7 @@ async function run(
715721
return fileName;
716722
}
717723
} catch (e) {
718-
console.error('Error using SAFDocumentFile:', e);
724+
console.error("Error using SAFDocumentFile:", e);
719725
// Fall through to existing logic
720726
}
721727
}
@@ -798,4 +804,4 @@ async function run(
798804
}
799805
}
800806

801-
export default run;
807+
export default run;

0 commit comments

Comments
 (0)