diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-13 23:33:11 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-13 23:33:11 +0200 |
| commit | 8eab68f2c5a3c126e2fec2ecdfa7ace87ce0937b (patch) | |
| tree | f446ebc26a7707c7b64a937aa51a155df146c80a /app/controllers/application_controller.rb | |
| parent | 42714c697273a7117c6b355fab26c8c35e336ad1 (diff) | |
| parent | cdf5d9941ca866d437612d2f863eac6eb0b3db12 (diff) | |
Merge branch 'erdgeist-revive-events'
Diffstat (limited to 'app/controllers/application_controller.rb')
| -rw-r--r-- | app/controllers/application_controller.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 75f92c3..cbeb40d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb | |||
| @@ -5,6 +5,8 @@ class ApplicationController < ActionController::Base | |||
| 5 | 5 | ||
| 6 | before_action :set_locale | 6 | before_action :set_locale |
| 7 | 7 | ||
| 8 | helper_method :safe_return_to | ||
| 9 | |||
| 8 | protected | 10 | protected |
| 9 | 11 | ||
| 10 | def set_locale | 12 | def set_locale |
| @@ -18,4 +20,14 @@ class ApplicationController < ActionController::Base | |||
| 18 | def default_url_options | 20 | def default_url_options |
| 19 | { locale: I18n.locale == I18n.default_locale ? nil : I18n.locale } | 21 | { locale: I18n.locale == I18n.default_locale ? nil : I18n.locale } |
| 20 | end | 22 | end |
| 23 | |||
| 24 | def safe_return_to(url) | ||
| 25 | return events_path if url.blank? | ||
| 26 | uri = URI.parse(url) | ||
| 27 | return events_path if uri.host.present? | ||
| 28 | return events_path unless url.start_with?('/') | ||
| 29 | url | ||
| 30 | rescue URI::InvalidURIError | ||
| 31 | events_path | ||
| 32 | end | ||
| 21 | end | 33 | end |
