Merge remote-tracking branch 'origin/main' into feature/399
このコミットが含まれているのは:
@@ -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
|
||||
@@ -174,5 +174,14 @@ class Post < ApplicationRecord
|
||||
return if url.blank?
|
||||
|
||||
self.url = PostUrlNormaliser.normalise(url) || url.strip
|
||||
|
||||
u = URI.parse(url)
|
||||
return unless u in URI::HTTP
|
||||
|
||||
u.host = u.host.downcase if u.host
|
||||
u.path = u.path.sub(/\/\Z/, '') if u.path.present?
|
||||
self.url = PostUrlSanitisationRule.sanitise(u.to_s)
|
||||
rescue URI::InvalidURIError
|
||||
;
|
||||
end
|
||||
end
|
||||
|
||||
新しい課題から参照
ユーザをブロックする