Sha256: 2994b423945ba5e94f3699a935d12a57624828f58bae0b683978c137550f4d00
Contents?: true
Size: 993 Bytes
Versions: 1
Compression:
Stored size: 993 Bytes
Contents
module Harpiya class LocaleController < Harpiya::StoreController REDIRECT_TO_ROOT = /\/(#{Harpiya::Config[:storefront_pages_path]})\//.freeze def index render :index, layout: false end def set new_locale = (params[:switch_to_locale] || params[:locale]).to_s if new_locale.present? && supported_locale?(new_locale) if should_build_new_url? redirect_to BuildLocalizedRedirectUrl.call( url: request.env['HTTP_REFERER'], locale: new_locale, default_locale: current_store.default_locale ).value else redirect_to root_path(locale: new_locale) end else redirect_to root_path end end private def should_build_new_url? if request.env['HTTP_REFERER'].match(REDIRECT_TO_ROOT) false else request.env['HTTP_REFERER'].present? && request.env['HTTP_REFERER'] != request.env['REQUEST_URI'] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
harpiya_frontend-4.3.0.alpha | app/controllers/harpiya/locale_controller.rb |