fix(config): enables quoted ; as values in ini files

Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
Deluan
2025-11-22 20:14:44 -05:00
parent ee51bd9281
commit c21aee7360
6 changed files with 17 additions and 3 deletions
+6 -1
View File
@@ -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)
+1
View File
@@ -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))
+2 -1
View File
@@ -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
+3
View File
@@ -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",
+2
View File
@@ -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"]
+2
View File
@@ -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