Skip to content

Commit bbb420d

Browse files
committed
Ensure canonical path on TempDir()
1 parent f85d686 commit bbb420d

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

constructors.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func NullPath() *Path {
4545

4646
// TempDir returns the default path to use for temporary files
4747
func TempDir() *Path {
48-
return New(os.TempDir())
48+
return New(os.TempDir()).Canonical()
4949
}
5050

5151
// MkTempDir creates a new temporary directory in the directory

paths_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ func TestReadFileAsLines(t *testing.T) {
208208
require.Equal(t, "line 3", lines[3])
209209
}
210210

211+
func TestCanonicaTempDir(t *testing.T) {
212+
require.Equal(t, TempDir().String(), TempDir().Canonical().String())
213+
}
214+
211215
func TestCopyDir(t *testing.T) {
212216
tmp, err := MkTempDir("", "")
213217
require.NoError(t, err)

0 commit comments

Comments
 (0)