Skip to content
Open
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
13 changes: 11 additions & 2 deletions backend/pkg/spa/pathSafety_internal_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package spa

import "testing"
import (
"runtime"
"testing"
)

func TestURLToRelRejectsUnsafePaths(t *testing.T) {
tests := []struct {
Expand All @@ -27,7 +30,13 @@ func TestURLToRelAcceptsSafeRelativePath(t *testing.T) {
t.Fatalf("expected safe path to be accepted")
}

if rel != "headlamp/assets/main.js" {
// On Windows, filepath.FromSlash converts / to \
expected := "headlamp/assets/main.js"
if runtime.GOOS == "windows" {
expected = "headlamp\\assets\\main.js"
}

if rel != expected {
t.Fatalf("unexpected relative path: got %q", rel)
}
}