Class: Decidim::DecidimAwesome::Admin::CustomRedirectForm
- Inherits:
-
Form
- Object
- Form
- Decidim::DecidimAwesome::Admin::CustomRedirectForm
- Includes:
- TranslatableAttributes
- Defined in:
- app/forms/decidim/decidim_awesome/admin/custom_redirect_form.rb
Instance Method Summary collapse
Instance Method Details
#sanitize_url(url, strip_host: true) ⇒ Object
27 28 29 30 31 32 33 |
# File 'app/forms/decidim/decidim_awesome/admin/custom_redirect_form.rb', line 27 def sanitize_url(url, strip_host: true) url = url.strip parsed = Addressable::URI.parse(url) url = parsed.path if strip_host && parsed.host == current_organization.host url = "/#{url}" unless url.match?(%r{^https?://|^/}) url end |
#to_params ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'app/forms/decidim/decidim_awesome/admin/custom_redirect_form.rb', line 16 def to_params [ sanitize_url(origin), { destination: sanitize_url(destination, strip_host: false), active:, pass_query: } ] end |