diff --git a/lib/family.rb b/lib/family.rb index f5f25cb..5c6db33 100644 --- a/lib/family.rb +++ b/lib/family.rb @@ -1,6 +1,8 @@ # Adds operatingsystem family behaviour to the Operatingsystem class # The variant is calculated at run-time require 'ostruct' +require 'uri' + module Family # NEVER, EVER reorder this list. Additions are allowed but offsets are encoded in the database FAMILIES = [:Debian, :RedHat, :Solaris] @@ -16,12 +18,11 @@ module Family include Family def preseed_server media - media.path.match('^(\w+):\/\/((\w|\.)+)((\w|\/)+)$')[2] + URI.parse(media.path).normalize.select(:host, :port).compact.join(':') end - #TODO: rethink of a more generic way def preseed_path media - media.path.match('^(\w+):\/\/((\w|\.)+)((\w|\/)+)$')[4] + URI.parse(media.path).normalize.select(:path, :query).compact.join('?') end end