Remove zero-padding from account slug

This shortens URLs in the self-hosted case, where external account ID is
typically a small number.
This commit is contained in:
Kevin McConnell
2026-01-28 11:48:38 +00:00
parent c059e0b216
commit e105ca6fb5
2 changed files with 11 additions and 3 deletions
@@ -1,6 +1,5 @@
module AccountSlug
PATTERN = /(\d{7,})/
FORMAT = "%07d"
PATTERN = /(\d+)/
PATH_INFO_MATCH = /\A(\/#{AccountSlug::PATTERN})/
class Extractor
@@ -40,7 +39,7 @@ module AccountSlug
end
def self.decode(slug) slug.to_i end
def self.encode(id) FORMAT % id end
def self.encode(id) id.to_s end
end
Rails.application.config.middleware.insert_after Rack::TempfileReaper, AccountSlug::Extractor