@lvce-editor/chat-tool-worker 9.4.0 → 9.5.0
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/chatToolWorkerMain.js +9 -10
- package/package.json +1 -1
|
@@ -1248,14 +1248,16 @@ const isAbsoluteUri = value => {
|
|
|
1248
1248
|
return ABSOLUTE_URI_REGEX.test(value);
|
|
1249
1249
|
};
|
|
1250
1250
|
|
|
1251
|
+
const isValidUri = value => {
|
|
1252
|
+
return URL.canParse(value);
|
|
1253
|
+
};
|
|
1254
|
+
|
|
1251
1255
|
const executeCreateDirectoryTool = async (args, _options) => {
|
|
1252
1256
|
const uri = typeof args.uri === 'string' ? args.uri : '';
|
|
1253
1257
|
if (!uri || !isAbsoluteUri(uri)) {
|
|
1254
1258
|
return getInvalidUriErrorPayload('uri');
|
|
1255
1259
|
}
|
|
1256
|
-
|
|
1257
|
-
new URL(uri);
|
|
1258
|
-
} catch {
|
|
1260
|
+
if (!isValidUri(uri)) {
|
|
1259
1261
|
return getInvalidUrlErrorPayload();
|
|
1260
1262
|
}
|
|
1261
1263
|
try {
|
|
@@ -1287,9 +1289,7 @@ const executeEditFileTool = async (args, _options) => {
|
|
|
1287
1289
|
if (!uri || !isAbsoluteUri(uri)) {
|
|
1288
1290
|
return getInvalidUriErrorPayload('uri');
|
|
1289
1291
|
}
|
|
1290
|
-
|
|
1291
|
-
new URL(uri);
|
|
1292
|
-
} catch {
|
|
1292
|
+
if (!isValidUri(uri)) {
|
|
1293
1293
|
return getInvalidUrlErrorPayload();
|
|
1294
1294
|
}
|
|
1295
1295
|
if (!Number.isInteger(start) || start < 0) {
|
|
@@ -1336,6 +1336,7 @@ const normalizeWorkspaceUri = workspacePathOrUri => {
|
|
|
1336
1336
|
url.pathname = windowsDrivePathRegex.test(workspacePathOrUri) ? `/${workspacePathOrUri.replaceAll('\\', '/')}` : workspacePathOrUri;
|
|
1337
1337
|
return url.href;
|
|
1338
1338
|
};
|
|
1339
|
+
|
|
1339
1340
|
const executeGetWorkspaceUriTool = async (_args, _options) => {
|
|
1340
1341
|
try {
|
|
1341
1342
|
const workspacePathOrUri = await getWorkspacePath();
|
|
@@ -1999,7 +2000,7 @@ const executeRenameTool = async (args, _options) => {
|
|
|
1999
2000
|
if (!newUri || !isAbsoluteUri(newUri)) {
|
|
2000
2001
|
return getInvalidUriErrorPayload('newUri');
|
|
2001
2002
|
}
|
|
2002
|
-
if (!
|
|
2003
|
+
if (!isValidUri(oldUri) || !isValidUri(newUri)) {
|
|
2003
2004
|
return getInvalidUrlErrorPayload();
|
|
2004
2005
|
}
|
|
2005
2006
|
const oldUrl = new URL(oldUri);
|
|
@@ -2339,9 +2340,7 @@ const executeWriteFileTool = async (args, _options) => {
|
|
|
2339
2340
|
if (!uri || !isAbsoluteUri(uri)) {
|
|
2340
2341
|
return getInvalidUriErrorPayload('uri');
|
|
2341
2342
|
}
|
|
2342
|
-
|
|
2343
|
-
new URL(uri);
|
|
2344
|
-
} catch {
|
|
2343
|
+
if (!isValidUri(uri)) {
|
|
2345
2344
|
return getInvalidUrlErrorPayload();
|
|
2346
2345
|
}
|
|
2347
2346
|
try {
|