Skip to content

Commit

Permalink
spike: capture and redirect accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
donrestarone committed Dec 1, 2024
1 parent e0e0388 commit c1dfc0f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 34 deletions.
33 changes: 0 additions & 33 deletions app/controllers/comfy/cms/base_controller.rb

This file was deleted.

5 changes: 5 additions & 0 deletions app/controllers/comfy/cms/content_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ class Comfy::Cms::ContentController < Comfy::Cms::BaseController
only: :show

def show
if params[:s2_redirect_to] && params[:s2_query] && params[:s2_url_params] && params[:s2_subdomain]
# s2 link detected, process accordingly
return redirect_to "https://#{params[:s2_redirect_to]}"
end

if @cms_page.target_page.present?
redirect_to @cms_page.target_page.url(relative: true)
else
Expand Down
15 changes: 14 additions & 1 deletion app/controllers/content_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
class ContentController < ApplicationController
before_action :track_ahoy_visit, raise: false
before_action :track_ahoy_visit, :process_subdomain_smart_link_redirect, raise: false

private

def process_subdomain_smart_link_redirect
subdomain = request.subdomain
url_parameters = request.path
if !subdomain.blank?
unless Subdomain.all.pluck(:name).any?{|name| subdomain == name}
# process S2 link - append parameters for 2nd redirect
return redirect_to "#{root_url(subdomain: Subdomain.current.name)}?s2_redirect_to=#{subdomain}&s2_query=#{subdomain}&s2_url_params=#{url_parameters}&s2_subdomain=#{subdomain}"
end
end
end
end

0 comments on commit c1dfc0f

Please sign in to comment.