Ensure replacement only at start of string
This commit is contained in:
parent
5f6077d171
commit
ca44dd4e23
1 changed files with 12 additions and 14 deletions
|
|
@ -38,25 +38,23 @@ const ShareSlashCommand: SlashCommand = {
|
|||
if (!outputDir) {
|
||||
outputDir = await ide.getContinueDir();
|
||||
}
|
||||
|
||||
if (outputDir.startsWith("~")) {
|
||||
outputDir = outputDir.replace(/~/, homedir);
|
||||
}
|
||||
//TODO: error handling, create path if it doesn't exist?
|
||||
|
||||
const workspaceDirs = await ide.getWorkspaceDirs();
|
||||
|
||||
// Although the most common situation is to have one directory open in a
|
||||
// workspace it's also possible to have just a file open without an
|
||||
// associated directory or to use multi-root workspaces in which multiple
|
||||
// folders are included. We default to using the first item in the list, if
|
||||
// it exists.
|
||||
const workspaceDirectory = workspaceDirs?.[0] || "";
|
||||
if (
|
||||
outputDir = outputDir.replace(/^~/, homedir);
|
||||
} else if (
|
||||
outputDir.startsWith("./") ||
|
||||
outputDir.startsWith(`.\\`) ||
|
||||
outputDir === "."
|
||||
) {
|
||||
outputDir = outputDir.replace(".", workspaceDirectory);
|
||||
const workspaceDirs = await ide.getWorkspaceDirs();
|
||||
// Although the most common situation is to have one directory open in a
|
||||
// workspace it's also possible to have just a file open without an
|
||||
// associated directory or to use multi-root workspaces in which multiple
|
||||
// folders are included. We default to using the first item in the list, if
|
||||
// it exists.
|
||||
const workspaceDirectory = workspaceDirs?.[0] || "";
|
||||
outputDir = outputDir.replace(/^./, workspaceDirectory);
|
||||
}
|
||||
}
|
||||
|
||||
const dtString = asBasicISOString(getOffsetDatetime(now));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue