lib/ahoy_email/processor.rb in ahoy_email-0.4.0 vs lib/ahoy_email/processor.rb in ahoy_email-0.5.0

- old
+ new

@@ -80,11 +80,11 @@ controller: "ahoy/messages", action: "open", id: ahoy_message.token, format: "gif" ) - pixel = ActionController::Base.helpers.image_tag(url, size: "1x1", alt: nil) + pixel = ActionController::Base.helpers.image_tag(url, size: "1x1", alt: "") # try to add before body tag if raw_source.match(regex) raw_source.gsub!(regex, "#{pixel}\\0") else @@ -101,12 +101,13 @@ doc.css("a[href]").each do |link| uri = parse_uri(link["href"]) next unless trackable?(uri) # utm params first if options[:utm_params] && !skip_attribute?(link, "utm-params") - params = uri.query_values || {} + params = uri.query_values(Array) || [] UTM_PARAMETERS.each do |key| - params[key] ||= options[key.to_sym] if options[key.to_sym] + next if params.any? { |k, _v| k == key } || !options[key.to_sym] + params << [key, options[key.to_sym]] end uri.query_values = params link["href"] = uri.to_s end