aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2025-02-24 12:38:18 +0100
committerGitHub Enterprise <[email protected]>2025-02-24 12:38:18 +0100
commit574c62a94f61265be5ae3d086834fa8b9d29eefc (patch)
treef17d65fffe1e761686be94a650f11afb0d4585f2 /src
parentmove WriteToTempFile to basicfile.h (#283) (diff)
downloadzen-574c62a94f61265be5ae3d086834fa8b9d29eefc.tar.xz
zen-574c62a94f61265be5ae3d086834fa8b9d29eefc.zip
strip leading path separator when creating workspace shares (#285)
Diffstat (limited to 'src')
-rw-r--r--src/zen/cmds/workspaces_cmd.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/zen/cmds/workspaces_cmd.cpp b/src/zen/cmds/workspaces_cmd.cpp
index 05d3c573f..166d4218d 100644
--- a/src/zen/cmds/workspaces_cmd.cpp
+++ b/src/zen/cmds/workspaces_cmd.cpp
@@ -25,7 +25,7 @@ namespace {
if (!Path.empty())
{
std::u8string PathString = Path.u8string();
- if (PathString.ends_with(std::filesystem::path::preferred_separator))
+ if (PathString.ends_with(std::filesystem::path::preferred_separator) || PathString.ends_with('/'))
{
PathString.pop_back();
Path = std::filesystem::path(PathString);
@@ -42,6 +42,19 @@ namespace {
}
}
+ static void RemoveLeadingPathSeparator(std::filesystem::path& Path)
+ {
+ if (!Path.empty())
+ {
+ std::u8string PathString = Path.u8string();
+ if (PathString.starts_with(std::filesystem::path::preferred_separator) || PathString.starts_with('/'))
+ {
+ PathString.erase(PathString.begin());
+ Path = std::filesystem::path(PathString);
+ }
+ }
+ }
+
void ShowShare(const Workspaces::WorkspaceShareConfiguration& Share, const Oid& WorkspaceId, std::string_view Prefix)
{
ZEN_CONSOLE("{}Id: {}", Prefix, Share.Id);
@@ -451,6 +464,7 @@ WorkspaceShareCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char**
}
RemoveTrailingPathSeparator(m_SharePath);
+ RemoveLeadingPathSeparator(m_SharePath);
if (m_ShareId.empty())
{