- Try parsing a url when setting source

This commit is contained in:
Jordan Sissel 2011-04-06 01:50:58 -07:00
parent 0fafebd2c7
commit b7d24943ea

View file

@ -47,12 +47,15 @@ class LogStash::Event
public
def source; @data["@source"]; end # def source
def source=(val)
uri = URI.parse(val) rescue nil
val = uri if uri
if val.is_a?(URI)
@data["@source"] = val.to_s
@data["@source_host"] = val.host
@data["@source_path"] = val.path
else
@data["@source"] = val
@data["@source_host"] = val
end
end # def source=