From 63196e018a3874641f01ac73d8e8f82fe3b38d92 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 6 Apr 2023 16:47:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=EF=BC=9A=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=A0=87=E8=AF=86=E6=AD=A3=E5=88=99=E8=A7=84?= =?UTF-8?q?=E5=88=99=E4=BB=A5=E5=8F=8A=E5=B8=A6.=E4=BB=93=E5=BA=93?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=AD=A3=E5=B8=B8=E6=98=BE=E7=A4=BA=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/libs/custom_regexp.rb | 2 +- config/routes.rb | 4 ++-- config/routes/api.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/libs/custom_regexp.rb b/app/libs/custom_regexp.rb index 889da4df8..1bfeb4b71 100644 --- a/app/libs/custom_regexp.rb +++ b/app/libs/custom_regexp.rb @@ -10,6 +10,6 @@ module CustomRegexp IP = /^((\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])\.){3}(\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])$/ URL_REGEX = /\A(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?\z/i - REPOSITORY_NAME_REGEX = /^(?!_)(?!.*?_$)[a-zA-Z0-9_-]+$/ #只含有数字、字母、下划线不能以下划线开头和结尾 + REPOSITORY_NAME_REGEX = /^[a-zA-Z0-9][a-zA-Z0-9\-\_\.]+$/ #只含有数字、字母、下划线不能以下划线开头和结尾 MD_REGEX = /^.+(\.[m|M][d|D])$/ end diff --git a/config/routes.rb b/config/routes.rb index 0d29e403f..7e69c2e38 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -451,7 +451,7 @@ Rails.application.routes.draw do namespace :traces do resources :trace_users, only: [:create] - scope "/:owner/:repo" do + scope "/:owner/:repo", constraints: { repo: /[^\/]+/ } do resource :projects, path: '/', only: [:index] do member do post :tasks @@ -464,7 +464,7 @@ Rails.application.routes.draw do end # Project Area START - scope "/:owner/:repo" do + scope "/:owner/:repo",constraints: { repo: /[^\/]+/ } do scope do get( '/activity', diff --git a/config/routes/api.rb b/config/routes/api.rb index 6e688a632..f39fa76c5 100644 --- a/config/routes/api.rb +++ b/config/routes/api.rb @@ -18,7 +18,7 @@ defaults format: :json do resources :feedbacks, only: [:create] end - scope ':repo' do + scope ':repo', constraints: { repo: /[^\/]+/ } do # projects resource :projects, path: '/', only: [:show, :update, :edit, :destroy] do collection do