From b383ad24409692e64c505bc1fc881db861f5e27d Mon Sep 17 00:00:00 2001 From: Evan Simkowitz Date: Fri, 24 Jan 2025 13:44:01 -0800 Subject: [PATCH] Fix connparse for wsl connections --- pkg/remote/connparse/connparse.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/pkg/remote/connparse/connparse.go b/pkg/remote/connparse/connparse.go index 4f045e637c..1114c3dfd5 100644 --- a/pkg/remote/connparse/connparse.go +++ b/pkg/remote/connparse/connparse.go @@ -23,6 +23,7 @@ const ( ) var windowsDriveRegex = regexp.MustCompile(`^[a-zA-Z]:`) +var wslConnRegex = regexp.MustCompile(`^wsl://[^/]+`) type Connection struct { Scheme string @@ -117,12 +118,17 @@ func ParseURI(uri string) (*Connection, error) { remotePath = rest } } else { - split = strings.SplitN(rest, "/", 2) - host = split[0] - if len(split) > 1 { - remotePath = split[1] + if strings.HasPrefix(rest, "wsl://") { + host = wslConnRegex.FindString(rest) + remotePath = strings.TrimPrefix(rest, host) } else { - remotePath = "/" + split = strings.SplitN(rest, "/", 2) + host = split[0] + if len(split) > 1 { + remotePath = split[1] + } else { + remotePath = "/" + } } }