Sha256: 839941bf92c257efd955898ce65692465f608f4735bebf35cc0da989982d55bc

Contents?: true

Size: 570 Bytes

Versions: 6

Compression:

Stored size: 570 Bytes

Contents

# frozen_string_literal: true

module PlatformosCheck
  class FormAction < HtmlCheck
    severity :error
    categories :html
    doc docs_url(__FILE__)

    VALID_ACTION_START = ['/', '{%', '{{', '#', 'http'].freeze

    def on_form(node)
      action = node.attributes["action"]&.strip
      return if action.nil?
      return if action.empty?
      return if action.start_with?(*VALID_ACTION_START)

      add_offense("Use action=\"/#{action}\" (start with /) to ensure the form can be submitted multiple times in case of validation errors", node:)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
platformos-check-0.4.14 lib/platformos_check/checks/form_action.rb
platformos-check-0.4.13 lib/platformos_check/checks/form_action.rb
platformos-check-0.4.12 lib/platformos_check/checks/form_action.rb
platformos-check-0.4.11 lib/platformos_check/checks/form_action.rb
platformos-check-0.4.10 lib/platformos_check/checks/form_action.rb
platformos-check-0.4.9 lib/platformos_check/checks/form_action.rb