From bea1d3a614037b73c422d7a3ee164d27aebcd396 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 11 Nov 2024 16:15:03 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20usar=20la=20misma=20detecci=C3=B3n=20de?= =?UTF-8?q?=20nombres=20de=20sitios?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/routes.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 9d5c974a..3dfc4c85 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,10 @@ # frozen_string_literal: true +# Como el sitio puede contener puntos, no queremos confundirlos con +# tipos de contenido, por ejemplo que /sites/site.org no intente service +# text/org. +SITE_ID_RE = %r{[^/]+}.freeze + Rails.application.routes.draw do devise_for :usuaries get '/.well-known/change-password', to: redirect('/usuaries/edit') @@ -18,7 +23,7 @@ Rails.application.routes.draw do resources :remote_flags, only: %i[show] end - resources :sites, only: %i[index], constraints: { site_id: /[a-z0-9\-.]+/, id: /[a-z0-9\-.]+/ } do + resources :sites, only: %i[index], constraints: { site_id: SITE_ID_RE, id: SITE_ID_RE } do get :'invitades/cookie', to: 'invitades#cookie' post :'posts/:layout', to: 'posts#create', as: :posts @@ -42,12 +47,12 @@ Rails.application.routes.draw do # Las rutas privadas empiezan con una ruta Ășnica para poder hacer un # alias en nginx sin tener que usar expresiones regulares para # detectar el nombre del sitio. - get '/sites/private/:site_id(*file)', to: 'private#show', constraints: { site_id: %r{[^/]+} } + get '/sites/private/:site_id(*file)', to: 'private#show', constraints: { site_id: SITE_ID_RE } get '/env.js', to: 'env#index' match '/api/v3/projects/:site_id/notices' => 'api/v1/notices#create', via: %i[post] - resources :sites, constraints: { site_id: %r{[^/]+}, id: %r{[^/]+} } do + resources :sites, constraints: { site_id: SITE_ID_RE, id: SITE_ID_RE } do # Gestionar actualizaciones del sitio get 'pull', to: 'sites#fetch' post 'pull', to: 'sites#merge'