initial push

Former-commit-id: a03463b3f1
This commit is contained in:
2025-05-27 21:31:02 -05:00
parent c5d9ea36df
commit 15193cddce
5 changed files with 158 additions and 2 deletions

46
paths-utility.js Normal file
View File

@@ -0,0 +1,46 @@
const path = require("path");
const {URI} = require("vscode-uri");
function makeServerPath(fileName, replacement) {
if (fileName.startsWith("file:")) {
return fileName;
}
const serverPath = formatPath(__dirname + path.sep + "temp" + path.sep + fileName);
if (replacement) {
return serverPath.replace(
replacement.from,
replacement.to
);
}
return serverPath;
}
function makeClientPath(filePath, replacement) {
if (/^(file|https?):/.test(filePath)) {
return filePath;
}
const clientPath = filePath.split(/[/\\]/).pop();
if (replacement) {
return clientPath.replace(
replacement.from,
replacement.to
);
}
return clientPath;
}
function formatPath(filePath) {
return URI.file(filePath).toString();
}
exports.formatPath = formatPath;
exports.makeClientPath = makeClientPath;
exports.makeServerPath = makeServerPath;