module Storefront module UrlHelper def current_subdomain subdomain = request.subdomain.to_s.split(".").first subdomain = nil if subdomain == App.name (subdomain.blank? || subdomain == "www") ? nil : subdomain end def path_namespace?(*args) args.present? ? args.any? { |is| path_namespace == is.to_s } : path_namespace.present? end def path_namespace if @path_namespace.nil? if current_subdomain.present? @path_namespace = current_subdomain elsif params[:path_namespace] @path_namespace = params[:path_namespace] else parts = params[:controller].split("/") @path_namespace = parts.length > 1 ? parts.first : "" end end @path_namespace end def with_current_params(path_method, *args) send path_method, *(args << Rack::Utils.parse_query(request.query_string).merge(args.extract_options!)) end end end