Skip to content

Commit b868adf

Browse files
committed
Ensure canonical path on TempDir()
1 parent d3eb8f7 commit b868adf

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

constructors.go

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ func TestReadFileAsLines(t *testing.T) {
204204
require.Equal(t, "line 3", lines[3])
205205
}
206206

207+
func TestCanonicaTempDir(t *testing.T) {
208+
require.Equal(t, TempDir().String(), TempDir().Canonical().String())
209+
}
210+
207211
func TestCopyDir(t *testing.T) {
208212
tmp, err := MkTempDir("", "")
209213
require.NoError(t, err)

0 commit comments

Comments
 (0)