Skip to content

Commit

Permalink
Make file:// the default fs:url scheme (#4251)
Browse files Browse the repository at this point in the history
`fs:url` config entry should be a valid url so cozy-stack fail if it is
given an absolute path to a directory.

This PR makes `file://` the default `fs:url` scheme when it is omitted
and the value is an absolute path (i.e. it start with a `/`)

This allow defining `fs:url` config item or `COZY_FS_URL` config env
variable as an absolute path for better readability
  • Loading branch information
sblaisot authored Dec 5, 2023
2 parents 4281dc5 + 7c82d61 commit 8136f4a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/config/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,13 @@ func max(a, b int) int {

// UseViper sets the configured instance of Config
func UseViper(v *viper.Viper) error {
fsURL, err := url.Parse(v.GetString("fs.url"))
fs_url := v.GetString("fs.url")
// Allow for plain directory path as fs.url
// file:// is the default implicit scheme
if strings.HasPrefix(fs_url, "/") {
fs_url = "file://" + fs_url
}
fsURL, err := url.Parse(fs_url)
if err != nil {
return err
}
Expand Down

0 comments on commit 8136f4a

Please sign in to comment.