fix(config): enables quoted ; as values in ini files
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
@@ -617,7 +617,12 @@ func init() {
|
|||||||
|
|
||||||
func InitConfig(cfgFile string) {
|
func InitConfig(cfgFile string) {
|
||||||
codecRegistry := viper.NewCodecRegistry()
|
codecRegistry := viper.NewCodecRegistry()
|
||||||
_ = codecRegistry.RegisterCodec("ini", ini.Codec{})
|
_ = codecRegistry.RegisterCodec("ini", ini.Codec{
|
||||||
|
LoadOptions: ini.LoadOptions{
|
||||||
|
UnescapeValueDoubleQuotes: true,
|
||||||
|
UnescapeValueCommentSymbols: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
viper.SetOptions(viper.WithCodecRegistry(codecRegistry))
|
viper.SetOptions(viper.WithCodecRegistry(codecRegistry))
|
||||||
|
|
||||||
cfgFile = getConfigFile(cfgFile)
|
cfgFile = getConfigFile(cfgFile)
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ var _ = Describe("Configuration", func() {
|
|||||||
Expect(conf.Server.MusicFolder).To(Equal(fmt.Sprintf("/%s/music", format)))
|
Expect(conf.Server.MusicFolder).To(Equal(fmt.Sprintf("/%s/music", format)))
|
||||||
Expect(conf.Server.UIWelcomeMessage).To(Equal("Welcome " + format))
|
Expect(conf.Server.UIWelcomeMessage).To(Equal("Welcome " + format))
|
||||||
Expect(conf.Server.Tags["custom"].Aliases).To(Equal([]string{format, "test"}))
|
Expect(conf.Server.Tags["custom"].Aliases).To(Equal([]string{format, "test"}))
|
||||||
|
Expect(conf.Server.Tags["artist"].Split).To(Equal([]string{";"}))
|
||||||
|
|
||||||
// The config file used should be the one we created
|
// The config file used should be the one we created
|
||||||
Expect(conf.Server.ConfigFile).To(Equal(filename))
|
Expect(conf.Server.ConfigFile).To(Equal(filename))
|
||||||
|
|||||||
Vendored
+2
-1
@@ -1,6 +1,7 @@
|
|||||||
[default]
|
[default]
|
||||||
MusicFolder = /ini/music
|
MusicFolder = /ini/music
|
||||||
UIWelcomeMessage = Welcome ini
|
UIWelcomeMessage = 'Welcome ini' ; Just a comment to test the LoadOptions
|
||||||
|
|
||||||
[Tags]
|
[Tags]
|
||||||
Custom.Aliases = ini,test
|
Custom.Aliases = ini,test
|
||||||
|
artist.Split = ";" # Should be able to read ; as a separator
|
||||||
Vendored
+3
@@ -2,6 +2,9 @@
|
|||||||
"musicFolder": "/json/music",
|
"musicFolder": "/json/music",
|
||||||
"uiWelcomeMessage": "Welcome json",
|
"uiWelcomeMessage": "Welcome json",
|
||||||
"Tags": {
|
"Tags": {
|
||||||
|
"artist": {
|
||||||
|
"split": ";"
|
||||||
|
},
|
||||||
"custom": {
|
"custom": {
|
||||||
"aliases": [
|
"aliases": [
|
||||||
"json",
|
"json",
|
||||||
|
|||||||
Vendored
+2
@@ -1,5 +1,7 @@
|
|||||||
musicFolder = "/toml/music"
|
musicFolder = "/toml/music"
|
||||||
uiWelcomeMessage = "Welcome toml"
|
uiWelcomeMessage = "Welcome toml"
|
||||||
|
|
||||||
|
Tags.artist.Split = ';'
|
||||||
|
|
||||||
[Tags.custom]
|
[Tags.custom]
|
||||||
aliases = ["toml", "test"]
|
aliases = ["toml", "test"]
|
||||||
|
|||||||
Vendored
+2
@@ -1,6 +1,8 @@
|
|||||||
musicFolder: "/yaml/music"
|
musicFolder: "/yaml/music"
|
||||||
uiWelcomeMessage: "Welcome yaml"
|
uiWelcomeMessage: "Welcome yaml"
|
||||||
Tags:
|
Tags:
|
||||||
|
artist:
|
||||||
|
split: [";"]
|
||||||
custom:
|
custom:
|
||||||
aliases:
|
aliases:
|
||||||
- yaml
|
- yaml
|
||||||
|
|||||||
Reference in New Issue
Block a user