From ab42fb74766328ec7db6b118f6f7849686da8ff5 Mon Sep 17 00:00:00 2001 From: "vilet.yy" Date: Mon, 3 May 2021 19:40:30 +0800 Subject: [PATCH] add: projects redirect to --- app/controllers/main_controller.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index 7b7468f9..99f25dd8 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -21,6 +21,14 @@ class MainController < ApplicationController uid_logger("main start is #{cookies[:_educoder_session]}") end + if params[:path] && params[:path].start_with?('projects/') + project_id = params[:path].split("/")[1] + project = Project.find_by_id(project_id) + if project.present? + return redirect_to("/projects/#{project.owner.login}/#{project.identifier}", status: 301) + end + end + # TODO: 这块之后需要整合,者架构重新变化,统一跳转到index后再路由分发 if params[:path] && params[:path]&.include?("h5educoderbuild") && params[:path].split("/").first == "h5educoderbuild" render file: 'public/h5educoderbuild/index.html', :layout => false