diff --git a/app/controllers/articles_controller.rb b/app/controllers/articles_controller.rb index e06768190..869413251 100644 --- a/app/controllers/articles_controller.rb +++ b/app/controllers/articles_controller.rb @@ -153,7 +153,7 @@ class ArticlesController < ApplicationController return end if params[:destination] - redirect_to(params[:destination]) + redirect_to(URI.parse(params[:destination]).path) return end if params[:article][:video_thumbnail_url] diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index e98858d6c..bd36a91f8 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -107,7 +107,7 @@ class CommentsController < ApplicationController authorize @comment if @comment.update(permitted_attributes(@comment).merge(edited_at: Time.zone.now)) Mention.create_all(@comment) - redirect_to @comment.path, notice: "Comment was successfully updated." + redirect_to URI.parse(@comment.path).path, notice: "Comment was successfully updated." else @commentable = @comment.commentable render :edit @@ -125,7 +125,7 @@ class CommentsController < ApplicationController @comment.deleted = true @comment.save! end - redirect_to @commentable_path, notice: "Comment was successfully deleted." + redirect_to URI.parse(@commentable_path).path, notice: "Comment was successfully deleted." end def delete_confirm diff --git a/app/controllers/internal/welcome_controller.rb b/app/controllers/internal/welcome_controller.rb index 2d5fe905b..3c5ba28a7 100644 --- a/app/controllers/internal/welcome_controller.rb +++ b/app/controllers/internal/welcome_controller.rb @@ -10,7 +10,7 @@ class Internal::WelcomeController < Internal::ApplicationController body_markdown: welcome_thread_content, user: User.dev_account, ) - redirect_to welcome_thread.path + "/edit" + redirect_to URI.parse(welcome_thread.path).path + "/edit" end private diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index 225dd16fe..06849353e 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -54,10 +54,10 @@ class StoriesController < ApplicationController potential_username = params[:username].tr("@", "").downcase @user = User.find_by("old_username = ? OR old_old_username = ?", potential_username, potential_username) if @user&.articles&.find_by(slug: params[:slug]) - redirect_to "/#{@user.username}/#{params[:slug]}" + redirect_to URI.parse("/#{@user.username}/#{params[:slug]}").path return elsif (@organization = @article.organization) - redirect_to "/#{@organization.slug}/#{params[:slug]}" + redirect_to URI.parse("/#{@organization.slug}/#{params[:slug]}").path return end not_found diff --git a/app/controllers/tag_adjustments_controller.rb b/app/controllers/tag_adjustments_controller.rb index 36989852f..f3d5dc2e5 100644 --- a/app/controllers/tag_adjustments_controller.rb +++ b/app/controllers/tag_adjustments_controller.rb @@ -10,7 +10,7 @@ class TagAdjustmentsController < ApplicationController reason_for_adjustment: params[:tag_adjustment][:reason_for_adjustment], ).create @article = Article.find(params[:tag_adjustment][:article_id]) - redirect_to "#{@article.path}/mod" + redirect_to "#{URI.parse(@article.path).path}/mod" end def destroy @@ -19,6 +19,6 @@ class TagAdjustmentsController < ApplicationController tag_adjustment.destroy @article = Article.find(tag_adjustment.article_id) @article.update!(tag_list: @article.tag_list.add(tag_adjustment.tag_name)) - redirect_to "#{@article.path}/mod" + redirect_to "#{URI.parse(@article.path).path}/mod" end end diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index dc248385d..e23565af8 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -19,7 +19,7 @@ class TagsController < ApplicationController authorize @tag if @tag.errors.messages.blank? && @tag.update(tag_params) flash[:success] = "Tag successfully updated! 👍 " - redirect_to "/t/#{@tag.name}/edit" + redirect_to "/t/#{URI.parse(@tag.name).path}/edit" else flash[:error] = @tag.errors.full_messages render :edit