mirror of
https://github.com/go-task/task.git
synced 2026-07-07 22:18:47 +00:00
Refactor: Add SmartJoin to handle IsAbs automatically
This commit is contained in:
14
internal/filepathext/filepathext.go
Normal file
14
internal/filepathext/filepathext.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package filepathext
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// SmartJoin joins two paths, but only if the second is not already an
|
||||
// absolute path.
|
||||
func SmartJoin(a, b string) string {
|
||||
if filepath.IsAbs(b) {
|
||||
return b
|
||||
}
|
||||
return filepath.Join(a, b)
|
||||
}
|
||||
Reference in New Issue
Block a user