Sha256: 9f1b147fa3a7bb3cfc98decd985c64b52bc58c91f5fd24ae27ed1f370886138d
Contents?: true
Size: 923 Bytes
Versions: 18
Compression:
Stored size: 923 Bytes
Contents
# frozen_string_literal: true module Decidim class InvalidUrlError < StandardError; end class LinksController < Decidim::ApplicationController skip_before_action :store_current_location helper Decidim::ExternalDomainHelper before_action :parse_url rescue_from Decidim::InvalidUrlError, with: :invalid_url def new headers["X-Robots-Tag"] = "noindex" end private def invalid_url flash[:alert] = I18n.t("decidim.links.invalid_url") redirect_to decidim.root_path end def parse_url raise Decidim::InvalidUrlError unless external_url parts = external_url.match %r{^(([a-z]+):)?//([^/]+)(/.*)?$} raise Decidim::InvalidUrlError unless parts @url_parts = { protocol: parts[1], domain: parts[3], path: parts[4] } end def external_url @external_url ||= params[:external_url] end end end
Version data entries
18 entries across 18 versions & 1 rubygems