mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 11:27:52 +08:00
Strip trailing slashes from ScreeningUrl records
This commit is contained in:
@ -11,13 +11,16 @@ class ScreenedUrl < ActiveRecord::Base
|
||||
|
||||
default_action :do_nothing
|
||||
|
||||
before_validation :strip_http
|
||||
before_validation :normalize
|
||||
|
||||
validates :url, presence: true, uniqueness: true
|
||||
validates :domain, presence: true
|
||||
|
||||
def strip_http
|
||||
self.url.gsub!(/http(s?):\/\//i, '')
|
||||
def normalize
|
||||
if self.url
|
||||
self.url.gsub!(/http(s?):\/\//i, '')
|
||||
self.url.gsub!(/(\/)+$/, '') # trim trailing slashes
|
||||
end
|
||||
end
|
||||
|
||||
def self.watch(url, domain, opts={})
|
||||
|
Reference in New Issue
Block a user