Class: Slimmer::Processors::FeedbackURLSwapper

Inherits:
Object
  • Object
show all
Defined in:
lib/slimmer/processors/feedback_url_swapper.rb

Instance Method Summary collapse

Constructor Details

#initialize(request, headers) ⇒ FeedbackURLSwapper

Returns a new instance of FeedbackURLSwapper.



3
4
5
6
# File 'lib/slimmer/processors/feedback_url_swapper.rb', line 3

def initialize(request, headers)
  @headers = headers
  @request = request
end

Instance Method Details

#filter(_src, dest) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/slimmer/processors/feedback_url_swapper.rb', line 8

def filter(_src, dest)
  return dest unless is_gem_layout?

  original_url_without_pii = remove_pii(@request.base_url + @request.fullpath)
  dest.at_css(".gem-c-feedback input[name='url']")&.set_attribute("value", original_url_without_pii)

  full_path_without_pii = remove_pii(@request.fullpath)
  dest.at_css(".gem-c-feedback input[name='email_survey_signup[survey_source]']")&.set_attribute("value", full_path_without_pii)

  dest
end