mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 13:06:56 +08:00
allow onebox whitelist to be extended
This commit is contained in:
@ -8,10 +8,9 @@
|
|||||||
#******************************************************************************#
|
#******************************************************************************#
|
||||||
|
|
||||||
module Oneboxer
|
module Oneboxer
|
||||||
|
|
||||||
module Whitelist
|
module Whitelist
|
||||||
def self.entries
|
def self.entries
|
||||||
[
|
@entries ||= [
|
||||||
Entry.new(/^https?:\/\/(?:www\.)?findery\.com\/.+/),
|
Entry.new(/^https?:\/\/(?:www\.)?findery\.com\/.+/),
|
||||||
Entry.new(/^https?:\/\/(?:www\.)?zappos\.com\/.+/),
|
Entry.new(/^https?:\/\/(?:www\.)?zappos\.com\/.+/),
|
||||||
Entry.new(/^https?:\/\/(?:www\.)?slideshare\.net\/.+/),
|
Entry.new(/^https?:\/\/(?:www\.)?slideshare\.net\/.+/),
|
||||||
@ -97,24 +96,22 @@ module Oneboxer
|
|||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
class Entry
|
||||||
|
# oembed = false is probably safer, but this is the least-drastic change
|
||||||
class Entry
|
def initialize(pattern, oembed = true)
|
||||||
# oembed = false is probably safer, but this is the least-drastic change
|
@pattern = pattern
|
||||||
def initialize(pattern, oembed = true)
|
@oembed = oembed
|
||||||
@pattern = pattern
|
|
||||||
@oembed = oembed
|
|
||||||
end
|
|
||||||
|
|
||||||
def allows_oembed?
|
|
||||||
@oembed
|
|
||||||
end
|
|
||||||
|
|
||||||
def matches?(url)
|
|
||||||
url =~ @pattern
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def allows_oembed?
|
||||||
|
@oembed
|
||||||
|
end
|
||||||
|
|
||||||
|
def matches?(url)
|
||||||
|
url =~ @pattern
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user