Skip to content

Commit 103d056

Browse files
format
1 parent 2d66637 commit 103d056

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

src/lib/run.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import anchor from "markdown-it-anchor";
77
import MarkdownItGitHubAlerts from "markdown-it-github-alerts";
88
import mimeType from "mime-types";
99
import mustache from "mustache";
10+
import path from "path-browserify";
1011
import browser from "plugins/browser";
1112
import Url from "utils/Url";
1213
import helpers from "utils/helpers";
@@ -16,7 +17,6 @@ import constants from "./constants";
1617
import EditorFile from "./editorFile";
1718
import openFolder, { addedFolder } from "./openFolder";
1819
import appSettings from "./settings";
19-
import path from "path-browserify";
2020

2121
/**@type {Server} */
2222
let webServer;
@@ -257,21 +257,19 @@ async function run(
257257

258258
let url = activeFile.uri;
259259

260-
console.log("activeFile.uri", activeFile.uri);
261-
262260
let file = activeFile.SAFMode === "single" ? activeFile : null;
263261

264262
if (pathName) {
265263
let rootFolder = addedFolder[0].url;
266264
const query = url.split("?")[1];
267265

268-
//remove the query string if present this is needs to be removed because the url is not valid
266+
//remove the query string if present this is needs to be removed because the url is not valid
269267
if (rootFolder.startsWith("ftp:") || rootFolder.startsWith("sftp:")) {
270268
if (rootFolder.includes("?")) {
271-
rootFolder = rootFolder.split("?")[0];
269+
rootFolder = rootFolder.split("?")[0];
272270
}
273271
}
274-
272+
275273
url = Url.join(rootFolder, reqPath);
276274

277275
if (query) {
@@ -518,32 +516,36 @@ async function run(
518516
*/
519517
function openBrowser() {
520518
//get the project url
521-
let rootFolder = addedFolder[0].url
519+
let rootFolder = addedFolder[0].url;
522520

523521
//parent of the file
524-
let filePath = pathName
522+
let filePath = pathName;
525523

526524
//make the uri absolute if necessary
527-
if (rootFolder === "content://com.termux.documents/tree/%2Fdata%2Fdata%2Fcom.termux%2Ffiles%2Fhome") {
528-
rootFolder = "content://com.termux.documents/tree/%2Fdata%2Fdata%2Fcom.termux%2Ffiles%2Fhome::/data/data/com.termux/files/home/"
525+
if (
526+
rootFolder ===
527+
"content://com.termux.documents/tree/%2Fdata%2Fdata%2Fcom.termux%2Ffiles%2Fhome"
528+
) {
529+
rootFolder =
530+
"content://com.termux.documents/tree/%2Fdata%2Fdata%2Fcom.termux%2Ffiles%2Fhome::/data/data/com.termux/files/home/";
529531
}
530532

531-
//remove the query string if present this is needs to be removed because the url is not valid
533+
//remove the query string if present this is needs to be removed because the url is not valid
532534
if (rootFolder.startsWith("ftp:") || rootFolder.startsWith("sftp:")) {
533535
if (rootFolder.includes("?")) {
534536
rootFolder = rootFolder.split("?")[0];
535537
}
536538
}
537-
538-
//remove the query string if present this is needs to be removed because the url is not valid
539+
540+
//remove the query string if present this is needs to be removed because the url is not valid
539541
if (filePath.startsWith("ftp:") || rootFolder.startsWith("sftp:")) {
540542
if (filePath.includes("?")) {
541543
filePath = filePath.split("?")[0];
542544
}
543545
}
544546

545547
//subtract the root folder from the file path to get relative path
546-
const path = removePrefix(Url.join(filePath,filename),rootFolder)
548+
const path = removePrefix(Url.join(filePath, filename), rootFolder);
547549

548550
const src = `http://localhost:${port}/${path}`;
549551

@@ -556,4 +558,4 @@ async function run(
556558
}
557559
}
558560

559-
export default run;
561+
export default run;

0 commit comments

Comments
 (0)