@nextclaw/server 0.15.1 → 0.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +11 -3
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -4658,8 +4658,15 @@ var ServerPathBrowseError = class extends Error {
|
|
|
4658
4658
|
this.name = "ServerPathBrowseError";
|
|
4659
4659
|
}
|
|
4660
4660
|
};
|
|
4661
|
-
function normalizeBrowsePath(
|
|
4662
|
-
|
|
4661
|
+
function normalizeBrowsePath(options) {
|
|
4662
|
+
const { basePath, path } = options;
|
|
4663
|
+
const rawPath = typeof path === "string" ? path.trim() : "";
|
|
4664
|
+
const normalizedBasePath = typeof basePath === "string" ? basePath.trim() : "";
|
|
4665
|
+
if (!rawPath) return resolve(expandHome(normalizedBasePath || homedir()));
|
|
4666
|
+
const expandedPath = expandHome(rawPath);
|
|
4667
|
+
if (expandedPath.startsWith("/")) return resolve(expandedPath);
|
|
4668
|
+
if (!normalizedBasePath) throw new ServerPathBrowseError("SERVER_PATH_BASE_REQUIRED", "relative server path requires a base path");
|
|
4669
|
+
return resolve(expandHome(normalizedBasePath), expandedPath);
|
|
4663
4670
|
}
|
|
4664
4671
|
function readRootLabel(rootPath) {
|
|
4665
4672
|
return rootPath.replace(/[\\/]+$/, "") || rootPath;
|
|
@@ -4705,7 +4712,7 @@ function sortEntryViews(left, right) {
|
|
|
4705
4712
|
return left.name.localeCompare(right.name);
|
|
4706
4713
|
}
|
|
4707
4714
|
async function browseServerPath(options = {}) {
|
|
4708
|
-
const currentPath = normalizeBrowsePath(options
|
|
4715
|
+
const currentPath = normalizeBrowsePath(options);
|
|
4709
4716
|
let currentPathStats;
|
|
4710
4717
|
try {
|
|
4711
4718
|
currentPathStats = await stat(currentPath);
|
|
@@ -4971,6 +4978,7 @@ var ServerPathRoutesController = class {
|
|
|
4971
4978
|
try {
|
|
4972
4979
|
const payload = await browseServerPath({
|
|
4973
4980
|
path: c.req.query("path"),
|
|
4981
|
+
basePath: c.req.query("basePath"),
|
|
4974
4982
|
includeFiles: readIncludeFilesFlag(c.req.query("includeFiles"))
|
|
4975
4983
|
});
|
|
4976
4984
|
return c.json(ok(payload));
|