diff --git a/app/controllers/spree/static_content_controller.rb b/app/controllers/spree/static_content_controller.rb index 9aca45e0..8635405b 100644 --- a/app/controllers/spree/static_content_controller.rb +++ b/app/controllers/spree/static_content_controller.rb @@ -5,7 +5,7 @@ class Spree::StaticContentController < Spree::StoreController layout :determine_layout def show - @page = Spree::Page.by_store(current_store).visible.find_by_slug!(request.path) + @page = Spree::Page.by_store(current_store).visible.find_by_slug!(::StaticPage.remove_spree_mount_point_if_exists(request.path)) end private diff --git a/lib/spree_static_content.rb b/lib/spree_static_content.rb index a40032d2..93674936 100644 --- a/lib/spree_static_content.rb +++ b/lib/spree_static_content.rb @@ -8,11 +8,20 @@ def self.remove_spree_mount_point(path) regex = Regexp.new '\A' + Rails.application.routes.url_helpers.spree_path path.sub( regex, '').split('?')[0] end + + def self.remove_spree_mount_point_if_exists(path) + spree_path = Rails.application.routes.url_helpers.spree_path + if spree_path == "/" + return path + else + return remove_spree_mount_point(path) + end + end end class Spree::StaticPage def self.matches?(request) return false if request.path =~ /(^\/+(admin|account|cart|checkout|content|login|pg\/|orders|products|s\/|session|signup|shipments|states|t\/|tax_categories|user)+)/ - !Spree::Page.visible.find_by_slug(request.path).nil? + !Spree::Page.visible.find_by_slug(::StaticPage.remove_spree_mount_point_if_exists(request.path)).nil? end end