Module: Waitmate::TargetValidation

Extended by:
ActiveSupport::Concern
Included in:
ControllerConcern, RoomsController
Defined in:
lib/waitmate/controller_concern.rb

Overview

Shared validation for the relative target URL that is threaded between the host controller and the Engine waiting room. Keeping this in one place ensures the concern-emit path and the room-redirect path never diverge.

Instance Method Summary collapse

Instance Method Details

#valid_waiting_room_target?(target) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
# File 'lib/waitmate/controller_concern.rb', line 15

def valid_waiting_room_target?(target)
  return false unless target.is_a?(String) && target.start_with?("/")
  return false if target.start_with?("//")
  return false if target.include?("://")
  return false if target.match?(/\Ajavascript:/i)
  true
end