Sha256: 6279d4386f8957c374c6b177714ff87479dd63ab58894b15c239061e4dc3b414
Contents?: true
Size: 987 Bytes
Versions: 7
Compression:
Stored size: 987 Bytes
Contents
module Spree class LocaleController < Spree::StoreController REDIRECT_TO_ROOT = /\/(#{Spree::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
7 entries across 7 versions & 1 rubygems