Module: Jpmobile::TransSidRedirecting

Defined in:
lib/jpmobile/trans_sid.rb

Instance Method Summary collapse

Instance Method Details

#redirect_to(options = {}, response_status = {}) ⇒ Object


68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/jpmobile/trans_sid.rb', line 68

def redirect_to(options = {}, response_status = {})
  if apply_trans_sid? and jpmobile_session_id
    case options
    when %r{^\w[\w+.-]*:.*}
      # nothing to do
    when String
      unless options.match(/#{session_key}/)
        url = URI.parse(options)
        if url.query
          url.query += "&#{session_key}=#{jpmobile_session_id}"
        else
          url.query = "#{session_key}=#{jpmobile_session_id}"
        end
        options = url.to_s
      end
    when :back
      # nothing to do
    when Hash
      unless options[session_key.to_sym]
        options[session_key.to_sym] = jpmobile_session_id
      end
    else
      # nothing to do
    end
  end

  super(options, response_status)
end