5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-21 13:26:22 +00:00

fix: usar la misma detección de nombres de sitios

This commit is contained in:
f 2024-11-11 16:15:03 -03:00
parent f29bd2482e
commit bea1d3a614
No known key found for this signature in database

View file

@ -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'