Sha256: 2c51b9d29324d2fbfbb4cf9c68f662585d0e9a89dbbf837a4b7944683a8934cc
Contents?: true
Size: 1.34 KB
Versions: 19
Compression:
Stored size: 1.34 KB
Contents
# frozen_string_literal: true module Neetob class CLI module Redirections class Check < CLI::Base attr_accessor :sandbox, :source, :destination def initialize(source, destination, sandbox = false) super() @source = source @destination = destination @sandbox = sandbox end def run source_url = URI.parse(source) destination_url = URI.parse(destination) response = Net::HTTP.get_response(source_url) if response.code.in? %w(301 302 308) if response["location"].chomp("/") == destination.chomp("/") ui.success( "The redirection from #{source} to #{destination} is working properly.", print_to_audit_log: false) else ui.error( "The redirection from #{source} to #{destination} is not working properly.", print_to_audit_log: false) end else ui.error( "The redirection from #{source} to #{destination} is not working properly.", print_to_audit_log: false) end if Thread.current[:audit_mode] response.code.in?(%w(301 302 308)) && (response["location"].chomp("/") == destination.chomp("/")) end end end end end end
Version data entries
19 entries across 19 versions & 1 rubygems