URL 正規化 (#409) (#410)

Reviewed-on: #410
Co-authored-by: miteruzo <miteruzo@naver.com>
Co-committed-by: miteruzo <miteruzo@naver.com>
このコミットはPull リクエスト #410 でマージされました.
このコミットが含まれているのは:
2026-07-14 12:38:02 +09:00
committed by みてるぞ
コミット 38650b5671
9個のファイルの変更674行の追加5行の削除
+3 -3
ファイルの表示
@@ -57,9 +57,9 @@ class Post < ApplicationRecord
attribute :version_no, :integer, default: 1
before_validation :normalise_url
before_validation :normalise_url, if: :will_save_change_to_url?
validates :url, presence: true, uniqueness: true
validates :url, presence: true, uniqueness: true, length: { maximum: 768 }
validates :video_ms, numericality: { only_integer: true, greater_than: 0 }, allow_nil: true
validate :validate_original_created_range
@@ -180,7 +180,7 @@ class Post < ApplicationRecord
u.host = u.host.downcase if u.host
u.path = u.path.sub(/\/\Z/, '') if u.path.present?
self.url = u.to_s
self.url = PostUrlSanitisationRule.sanitise(u.to_s)
rescue URI::InvalidURIError
;
end