Skip to content

Commit

Permalink
Don't use storefront_*_path preferences in frontend gems
Browse files Browse the repository at this point in the history
  • Loading branch information
damianlegawiec committed Sep 21, 2021
1 parent 06c1c5b commit 842d2a0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion frontend/app/controllers/spree/locale_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Spree
class LocaleController < Spree::StoreController
REDIRECT_TO_ROOT = /\/(#{Spree::Config[:storefront_pages_path]})\//.freeze
REDIRECT_TO_ROOT = /\/(pages)\//.freeze

def index
render :index, layout: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class BuildLocalizedRedirectUrl

LOCALE_REGEX = /^\/[A-Za-z]{2}\/|^\/[A-Za-z]{2}-[A-Za-z]{2}\/|^\/[A-Za-z]{2}$|^\/[A-Za-z]{2}-[A-Za-z]{2}$/.freeze

SUPPORTED_PATHS_REGEX = /\/(#{Spree::Config[:storefront_products_path]}|#{Spree::Config[:storefront_taxons_path]}\/|cart|checkout|addresses|content|#{Spree::Config[:storefront_pages_path]})/.freeze
SUPPORTED_PATHS_REGEX = /\/(products|t\/|cart|checkout|addresses|content|pages)/.freeze

# rubocop:disable Lint/UnusedMethodArgument
def call(url:, locale:, default_locale: nil)
Expand Down
8 changes: 4 additions & 4 deletions frontend/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
scope '(:locale)', locale: /#{Spree.available_locales.join('|')}/, defaults: { locale: nil } do
root to: 'home#index'

resources :products, only: [:index, :show], path: "/#{Spree::Config[:storefront_products_path]}"
resources :products, only: [:index, :show], path: '/products'

get "/#{Spree::Config[:storefront_products_path]}/:id/related", to: 'products#related'
get '/products/:id/related', to: 'products#related'
# route globbing for pretty nested taxon and product paths
get "/#{Spree::Config[:storefront_taxons_path]}/*id", to: 'taxons#show', as: :nested_taxons
get '/t/*id', to: 'taxons#show', as: :nested_taxons
get '/product_carousel/:id', to: 'taxons#product_carousel'

# non-restful checkout stuff
Expand Down Expand Up @@ -34,7 +34,7 @@
get '/api_tokens', to: 'store#api_tokens'
post '/ensure_cart', to: 'store#ensure_cart'

get "#{Spree::Config[:storefront_pages_path]}/:slug", to: 'cms_pages#show', as: :page
get '/pages/:slug', to: 'cms_pages#show', as: :page

get '/forbidden', to: 'errors#forbidden', as: :forbidden
get '/unauthorized', to: 'errors#unauthorized', as: :unauthorized
Expand Down

0 comments on commit 842d2a0

Please sign in to comment.