0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-25 10:40:28 +01:00

Ensure redirects are dasherized at the point of routing.

Dieser Commit ist enthalten in:
Angus McLeod 2018-05-24 15:32:07 +10:00
Ursprung cf4beb7619
Commit 4f4b8c49b2

Datei anzeigen

@ -76,7 +76,7 @@ after_initialize do
::UsersController.class_eval do ::UsersController.class_eval do
def wizard_path def wizard_path
if custom_wizard_redirect = $redis.get('custom_wizard_redirect') if custom_wizard_redirect = $redis.get('custom_wizard_redirect')
"#{Discourse.base_url}/w/#{custom_wizard_redirect}" "#{Discourse.base_url}/w/#{custom_wizard_redirect.dasherize}"
else else
"#{Discourse.base_url}/wizard" "#{Discourse.base_url}/wizard"
end end
@ -92,7 +92,7 @@ after_initialize do
CustomWizard::Wizard.set_redirect(@user, wizard_id, url) CustomWizard::Wizard.set_redirect(@user, wizard_id, url)
end end
url = "/w/#{wizard_id}" url = "/w/#{wizard_id.dasherize}"
end end
super(url) super(url)
end end
@ -113,9 +113,12 @@ after_initialize do
def redirect_to_wizard_if_required def redirect_to_wizard_if_required
@wizard_id ||= current_user.custom_fields['redirect_to_wizard'] @wizard_id ||= current_user.custom_fields['redirect_to_wizard']
if @wizard_id && request.referer !~ /w/ && request.referer !~ /admin/ @excluded_routes ||= SiteSetting.wizard_redirect_exclude_paths.split('|') + ['/w/']
CustomWizard::Wizard.set_redirect(current_user, @wizard_id, request.referer) url = request.referer || request.original_url
redirect_to "/w/#{@wizard_id}"
if @wizard_id && request.format === 'text/html' && !@excluded_routes.any? { |str| /#{str}/ =~ url }
CustomWizard::Wizard.set_redirect(current_user, @wizard_id, request.referer) if request.referer !~ /\/w\//
redirect_to "/w/#{@wizard_id.dasherize}"
end end
end end
end end