Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ gotestsum = "latest"
description = "Create VSCode symlinks for tools not automatically handled by mise-vscode"
run = [
"mkdir -p .vscode/mise-tools",
"ln -sf $(mise exec golangci-lint@2.1.1 -- which golangci-lint) .vscode/mise-tools/golangci-lint",
"ln -sf $(mise exec -- which golangci-lint-v2) $(dirname $(mise exec -- which golangci-lint-v2))/golangci-lint || true",
"ln -sf $(mise exec -- which golangci-lint) .vscode/mise-tools/golangci-lint",
]

[hooks]
Expand Down
12 changes: 7 additions & 5 deletions internal/utils/references.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ func (rc *ReferenceClassification) JoinWith(relative string) (string, error) {
}

if rc.IsFile {
return rc.joinFilePath(relative)
joined := rc.joinFilePath(relative)
return joined, nil
}

// If base is a fragment, treat relative as the new reference
Expand All @@ -157,7 +158,8 @@ func (rc *ReferenceClassification) JoinWith(relative string) (string, error) {
}

// Fallback: treat as file path
return rc.joinFilePath(relative)
joined := rc.joinFilePath(relative)
return joined, nil
}

// joinURL joins this URL reference with a relative reference using the cached ParsedURL
Expand Down Expand Up @@ -185,11 +187,11 @@ func (rc *ReferenceClassification) joinURL(relative string) (string, error) {
}

// joinFilePath joins this file path reference with a relative path using cross-platform path handling
func (rc *ReferenceClassification) joinFilePath(relative string) (string, error) {
func (rc *ReferenceClassification) joinFilePath(relative string) string {
// If relative path is absolute, return it as-is
// Check for both OS-specific absolute paths and Unix-style absolute paths (for cross-platform compatibility)
if filepath.IsAbs(relative) || strings.HasPrefix(relative, "/") || rc.isWindowsAbsolutePath(relative) {
return relative, nil
return relative
}

// Determine the path separator style from the original path
Expand Down Expand Up @@ -217,7 +219,7 @@ func (rc *ReferenceClassification) joinFilePath(relative string) (string, error)
joined = strings.ReplaceAll(joined, "\\", "/")
}

return joined, nil
return joined
}

// getWindowsDir extracts the directory part from a Windows-style path
Expand Down
13 changes: 11 additions & 2 deletions internal/utils/references_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
)

func TestWindowsPathClassification_Success(t *testing.T) {
t.Parallel()

tests := []struct {
name string
windowsPath string
Expand Down Expand Up @@ -46,6 +48,7 @@ func TestWindowsPathClassification_Success(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
classification, err := ClassifyReference(tt.windowsPath)
require.NoError(t, err)
require.NotNil(t, classification)
Expand All @@ -60,6 +63,8 @@ func TestWindowsPathClassification_Success(t *testing.T) {
}

func TestWindowsPathJoining_Success(t *testing.T) {
t.Parallel()

tests := []struct {
name string
base string
Expand Down Expand Up @@ -87,8 +92,8 @@ func TestWindowsPathJoining_Success(t *testing.T) {
{
name: "windows path with absolute relative path",
base: "C:\\path\\to\\schemas\\user.json",
relative: "D:\\other\\path\\schema.json",
expected: "D:\\other\\path\\schema.json",
relative: "D:\\some\\path\\schema.json",
expected: "D:\\some\\path\\schema.json",
},
{
name: "windows path with fragment",
Expand All @@ -100,6 +105,7 @@ func TestWindowsPathJoining_Success(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
classification, err := ClassifyReference(tt.base)
require.NoError(t, err)
require.NotNil(t, classification)
Expand All @@ -113,6 +119,8 @@ func TestWindowsPathJoining_Success(t *testing.T) {
}

func TestWindowsPathJoinReference_Success(t *testing.T) {
t.Parallel()

tests := []struct {
name string
base string
Expand All @@ -135,6 +143,7 @@ func TestWindowsPathJoinReference_Success(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
result, err := JoinReference(tt.base, tt.relative)
require.NoError(t, err)
assert.Equal(t, tt.expected, result)
Expand Down
Loading