mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
FIX: discourse.conf not parsing out comments correctly
This commit is contained in:
parent
d4d5f739ea
commit
79a17d5c22
2 changed files with 4 additions and 2 deletions
|
@ -66,7 +66,7 @@ class GlobalSetting
|
|||
|
||||
def read
|
||||
ERB.new(File.read(@file)).result().split("\n").each do |line|
|
||||
if line =~ /([a-z_]+)\s*=\s*(\"([^\"]*)\"|\'([^\']*)\'|[^#]*)/
|
||||
if line =~ /^\s*([a-z_]+)\s*=\s*(\"([^\"]*)\"|\'([^\']*)\'|[^#]*)/
|
||||
@data[$1.strip.to_sym] = ($4 || $3 || $2).strip
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,10 +12,11 @@ describe GlobalSetting::FileProvider do
|
|||
f = Tempfile.new('foo')
|
||||
f.write(" # this is a comment\n")
|
||||
f.write("\n")
|
||||
f.write("a = 1000 # this is a comment\n")
|
||||
f.write(" a = 1000 # this is a comment\n")
|
||||
f.write("b = \"10 # = 00\" # this is a # comment\n")
|
||||
f.write("c = \'10 # = 00\' # this is a # comment\n")
|
||||
f.write("d =\n")
|
||||
f.write("#f = 1\n")
|
||||
f.close
|
||||
|
||||
provider = GlobalSetting::FileProvider.from(f.path)
|
||||
|
@ -25,6 +26,7 @@ describe GlobalSetting::FileProvider do
|
|||
expect(provider.lookup(:c,"")).to eq "10 # = 00"
|
||||
expect(provider.lookup(:d,"bob")).to eq nil
|
||||
expect(provider.lookup(:e,"bob")).to eq "bob"
|
||||
expect(provider.lookup(:f,"bob")).to eq "bob"
|
||||
|
||||
expect(provider.keys.sort).to eq [:a, :b, :c, :d]
|
||||
|
||||
|
|
Loading…
Reference in a new issue